diff --git a/cli/config/config.go b/cli/config/config.go index f5f7c17140..d6ad567bdb 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -17,7 +17,7 @@ import ( var ( Version = "dev" Env = "dev" - DefaultCloudEndpoint = "http://app.tracetest.io" + DefaultCloudEndpoint = "https://app.tracetest.io" DefaultCloudDomain = "tracetest.io" DefaultCloudPath = "/" ) diff --git a/go.mod b/go.mod index ab25316eb9..42301e39cd 100644 --- a/go.mod +++ b/go.mod @@ -52,6 +52,7 @@ require ( github.com/prometheus/prometheus v1.8.2-0.20211217191541-41f1a8125e66 github.com/pterm/pterm v0.12.69 github.com/rivo/tview v0.0.0-20240122063236-8526c9fe1b54 + github.com/rs/cors v1.8.0 github.com/segmentio/analytics-go/v3 v3.2.1 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index f5c16b2ae1..69af2e15b1 100644 --- a/go.sum +++ b/go.sum @@ -1669,6 +1669,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= diff --git a/server/otlp/http_server.go b/server/otlp/http_server.go index 949083a5e9..d1aa7ef58a 100644 --- a/server/otlp/http_server.go +++ b/server/otlp/http_server.go @@ -12,6 +12,7 @@ import ( "github.com/gorilla/handlers" "github.com/gorilla/mux" + "github.com/rs/cors" "go.uber.org/zap" "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" @@ -51,9 +52,21 @@ func (s *httpServer) Start() error { r := mux.NewRouter() r.HandleFunc("/v1/traces", s.Export).Methods("POST") + h := decompressBodyHandler( + s.logger, + handlers.ContentTypeHandler(r, protoBufContentType, jsonContentType), + ) + h = handlers.CompressHandler(h) + h = cors.New(cors.Options{ + AllowOriginFunc: func(origin string) bool { + return true + }, + AllowCredentials: true, + }).Handler(h) + s.hServer = &http.Server{ Addr: s.addr, - Handler: handlers.CompressHandler(decompressBodyHandler(s.logger, handlers.ContentTypeHandler(r, protoBufContentType, jsonContentType))), + Handler: h, } listener, err := net.Listen("tcp", s.addr) if err != nil {