Skip to content

Commit

Permalink
fix: allow cors for grpc gateway handler (#3574)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyoJerryYu authored Jun 21, 2024
1 parent 7593379 commit a09c669
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/router/api/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/reflection"
Expand Down Expand Up @@ -104,8 +105,12 @@ func (s *APIV1Service) RegisterGateway(ctx context.Context, echoServer *echo.Ech
if err := v1pb.RegisterIdentityProviderServiceHandler(ctx, gwMux, conn); err != nil {
return err
}
echoServer.Any("/api/v1/*", echo.WrapHandler(gwMux))
echoServer.Any("/file/*", echo.WrapHandler(gwMux))
gwGroup := echoServer.Group("")
gwGroup.Use(middleware.CORS())
handler := echo.WrapHandler(gwMux)

gwGroup.Any("/api/v1/*", handler)
gwGroup.Any("/file/*", handler)

// GRPC web proxy.
options := []grpcweb.Option{
Expand Down

0 comments on commit a09c669

Please sign in to comment.