From 8e1f1c91b5ba6145cfe8b7b60a84ec5e9120962f Mon Sep 17 00:00:00 2001 From: Maxim Pertsov Date: Thu, 5 Jan 2023 12:22:50 -0500 Subject: [PATCH 1/2] configure cors to allow all origins --- robot/web/web.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 } From e284bb5df7510c91c1de15690f0eca2d2ae04047 Mon Sep 17 00:00:00 2001 From: Maxim Pertsov Date: Thu, 12 Jan 2023 13:54:37 -0500 Subject: [PATCH 2/2] re-run ci