From 6d45616dbe501680c56d71b67c0d0aaafbbfdda4 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 19 Sep 2023 20:34:02 +0800 Subject: [PATCH] chore: add cors middleware --- server/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/server.go b/server/server.go index 2cbf5490..ddd66c4e 100644 --- a/server/server.go +++ b/server/server.go @@ -66,6 +66,12 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store e.Use(middleware.Gzip()) + e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ + Skipper: grpcRequestSkipper, + AllowOrigins: []string{"*"}, + AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete}, + })) + e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{ Skipper: grpcRequestSkipper, Timeout: 30 * time.Second,