mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
Implement CORS headers
This commit is contained in:
parent
bfe9c5b628
commit
215315af14
@ -58,8 +58,15 @@ func Serve() error {
|
||||
// Serve the web resources
|
||||
address := env.Get("WEB_ADDRESS", ":8080")
|
||||
return (&fasthttp.Server{
|
||||
Handler: router.Handler,
|
||||
Logger: new(nilLogger),
|
||||
Handler: func(ctx *fasthttp.RequestCtx) {
|
||||
// Add the CORS headers
|
||||
ctx.Response.Header.Set("Access-Control-Allow-Methods", "GET,POST,DELETE,OPTIONS")
|
||||
ctx.Response.Header.Set("Access-Control-Allow-Origin", "*")
|
||||
|
||||
// Call the router handler
|
||||
router.Handler(ctx)
|
||||
},
|
||||
Logger: new(nilLogger),
|
||||
}).ListenAndServe(address)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user