Skip to content

Commit

Permalink
set cors middleware in response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
2hmad committed Apr 13, 2023
1 parent 89d63b7 commit b1741b6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func (r *Router) Use(method string, middlewares ...interface{}) {
func CORSMiddleware() MiddlewareFunc {
return func(handler Handler) Handler {
return func(ctx *Context) error {
ctx.SetRequestHeader("Access-Control-Allow-Origin", "*")
ctx.SetRequestHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
ctx.SetRequestHeader("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
ctx.SetResponseHeader("Access-Control-Allow-Origin", "*")
ctx.SetResponseHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
ctx.SetResponseHeader("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
return handler(ctx)
}
}
Expand Down

0 comments on commit b1741b6

Please sign in to comment.