Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-1646 Configure cors to allow all origins #1755

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions robot/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down