mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 12:03:14 +08:00
chore: add a new cors response header
This commit is contained in:
parent
fb1c0aa387
commit
2e87c6f4da
@ -63,6 +63,7 @@ func Start(addr string, tlsAddr string, secret string,
|
|||||||
AllowedHeaders: []string{"Content-Type", "Authorization"},
|
AllowedHeaders: []string{"Content-Type", "Authorization"},
|
||||||
MaxAge: 300,
|
MaxAge: 300,
|
||||||
})
|
})
|
||||||
|
r.Use(setPrivateNetworkAccess)
|
||||||
r.Use(corsM.Handler)
|
r.Use(corsM.Handler)
|
||||||
if isDebug {
|
if isDebug {
|
||||||
r.Mount("/debug", func() http.Handler {
|
r.Mount("/debug", func() http.Handler {
|
||||||
@ -149,6 +150,15 @@ func Start(addr string, tlsAddr string, secret string,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setPrivateNetworkAccess(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method == http.MethodOptions && r.Header.Get("Access-Control-Request-Method") != "" {
|
||||||
|
w.Header().Add("Access-Control-Allow-Private-Network", "true")
|
||||||
|
}
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func safeEuqal(a, b string) bool {
|
func safeEuqal(a, b string) bool {
|
||||||
aBuf := utils.ImmutableBytesFromString(a)
|
aBuf := utils.ImmutableBytesFromString(a)
|
||||||
bBuf := utils.ImmutableBytesFromString(b)
|
bBuf := utils.ImmutableBytesFromString(b)
|
||||||
|
Loading…
Reference in New Issue
Block a user