You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oa/libs/libs.go

26 lines
750 B
Go

//
// libs.go
// Copyright (C) 2024 veypi <i@veypi.com>
// 2024-11-04 21:50
// Distributed under terms of the GPL license.
//
package libs
import (
"net/http"
"github.com/veypi/OneBD/rest"
)
func CorsAllowAny(x *rest.X) {
origin := x.Request.Header.Get("Origin")
x.Header().Set("Access-Control-Allow-Origin", origin)
x.Header().Set("Access-Control-Allow-Credentials", "true")
x.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, PATCH, PROPFIND")
x.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, depth")
if x.Request.Method == http.MethodOptions && x.Request.Header.Get("Access-Control-Request-Method") != "" {
x.Stop()
}
}