gatus/controller/handler/cors.go

15 lines
369 B
Go
Raw Normal View History

2021-09-13 00:39:09 +02:00
package handler
import "net/http"
2021-09-13 00:39:09 +02:00
func DevelopmentCORS(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Access-Control-Allow-Origin", "http://localhost:8081")
if r.Method == "OPTIONS" {
return
}
next.ServeHTTP(w, r)
})
}