diff --git a/robot/web/web.go b/robot/web/web.go index 8f64916b3bb..e9aa393a033 100644 --- a/robot/web/web.go +++ b/robot/web/web.go @@ -27,6 +27,7 @@ import ( grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" "github.com/jhump/protoreflect/dynamic" "github.com/pkg/errors" + "github.com/rs/cors" "go.opencensus.io/trace" pb "go.viam.com/api/robot/v1" "go.viam.com/utils" @@ -1065,8 +1066,9 @@ func (svc *webService) initMux(options weboptions.Options) (*goji.Mux, error) { } // for urls with /api, add /viam to the path so that it matches with the paths defined in protobuf. - mux.Handle(pat.New("/api/*"), addPrefix(svc.rpcServer.GatewayHandler())) - mux.Handle(pat.New("/*"), svc.rpcServer.GRPCHandler()) + corsHandler := cors.AllowAll() + mux.Handle(pat.New("/api/*"), corsHandler.Handler(addPrefix(svc.rpcServer.GatewayHandler()))) + mux.Handle(pat.New("/*"), corsHandler.Handler(svc.rpcServer.GRPCHandler())) return mux, nil }