mirror of
https://github.com/openziti/zrok.git
synced 2024-11-23 00:23:48 +01:00
16 lines
511 B
Go
16 lines
511 B
Go
package util
|
|
|
|
import "net/http"
|
|
|
|
func cors(h http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
|
|
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PATCH, DELETE")
|
|
w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, ResponseType, User-Agent")
|
|
if r.Method == "OPTIONS" {
|
|
return
|
|
}
|
|
h.ServeHTTP(w, r)
|
|
})
|
|
}
|