Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: update cors middleware

Stevenc30d7ab8f3bf
diff --git a/server/server.go b/server/server.go
index 1cde55f2b..801981699 100644
--- a/server/server.go
+++ b/server/server.go
@@ -56,12 +56,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
`"status":${status},"error":"${error}"}` + "\n",
}))
- 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(CORSMiddleware())
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
@@ -198,7 +192,7 @@ func CORSMiddleware() echo.MiddlewareFunc {
w := c.Response().Writer
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
- w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
+ w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
w.Header().Set("Access-Control-Allow-Credentials", "true")
@@ -207,10 +201,7 @@ func CORSMiddleware() echo.MiddlewareFunc {
w.WriteHeader(http.StatusOK)
return nil
}
-
- // Continue processing request.
- next(c)
- return nil
+ return next(c)
}
}
}