mirror of
https://github.com/usememos/memos.git
synced 2024-12-27 07:30:52 +08:00
chore: update cors middleware
This commit is contained in:
parent
ab4a670bec
commit
c30d7ab8f3
1 changed files with 2 additions and 11 deletions
|
@ -56,12 +56,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
||||||
`"status":${status},"error":"${error}"}` + "\n",
|
`"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(CORSMiddleware())
|
||||||
|
|
||||||
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
|
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
|
||||||
|
@ -198,7 +192,7 @@ func CORSMiddleware() echo.MiddlewareFunc {
|
||||||
w := c.Response().Writer
|
w := c.Response().Writer
|
||||||
|
|
||||||
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
|
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-Headers", "Content-Type, Authorization")
|
||||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||||
|
|
||||||
|
@ -207,10 +201,7 @@ func CORSMiddleware() echo.MiddlewareFunc {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return next(c)
|
||||||
// Continue processing request.
|
|
||||||
next(c)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue