mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-05 14:09:57 +08:00
Improve setCorsHeaders() for "include" mode
This commit is contained in:
@ -24,16 +24,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
headerOrigin = "Origin"
|
headerOrigin = "Origin"
|
||||||
headerAllowOrigin = "Access-Control-Allow-Origin"
|
headerAllowOrigin = "Access-Control-Allow-Origin"
|
||||||
headerAllowMethods = "Access-Control-Allow-Methods"
|
headerAllowMethods = "Access-Control-Allow-Methods"
|
||||||
headerAllowHeaders = "Access-Control-Allow-Headers"
|
headerAllowHeaders = "Access-Control-Allow-Headers"
|
||||||
|
headerAllowCredentials = "Access-Control-Allow-Credentials"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setCorsHeaders(ctx *context.Context, origin string) {
|
func setCorsHeaders(ctx *context.Context, origin string) {
|
||||||
ctx.Output.Header(headerAllowOrigin, origin)
|
ctx.Output.Header(headerAllowOrigin, origin)
|
||||||
ctx.Output.Header(headerAllowMethods, "POST, GET, OPTIONS, DELETE")
|
ctx.Output.Header(headerAllowMethods, "POST, GET, OPTIONS, DELETE")
|
||||||
ctx.Output.Header(headerAllowHeaders, "Content-Type, Authorization")
|
ctx.Output.Header(headerAllowHeaders, "Content-Type, Authorization")
|
||||||
|
ctx.Output.Header(headerAllowCredentials, "true")
|
||||||
|
|
||||||
if ctx.Input.Method() == "OPTIONS" {
|
if ctx.Input.Method() == "OPTIONS" {
|
||||||
ctx.ResponseWriter.WriteHeader(http.StatusOK)
|
ctx.ResponseWriter.WriteHeader(http.StatusOK)
|
||||||
|
Reference in New Issue
Block a user