mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-09 20:10:27 +08:00
HTTP Header - CORS跨域设置增加多个选项
This commit is contained in:
@@ -1728,7 +1728,7 @@ func (this *HTTPRequest) processResponseHeaders(responseHeader http.Header, stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CORS
|
// CORS
|
||||||
if this.web.ResponseHeaderPolicy.CORS != nil && this.web.ResponseHeaderPolicy.CORS.IsOn {
|
if this.web.ResponseHeaderPolicy.CORS != nil && this.web.ResponseHeaderPolicy.CORS.IsOn && (!this.web.ResponseHeaderPolicy.CORS.OptionsMethodOnly || this.RawReq.Method == http.MethodOptions) {
|
||||||
var corsConfig = this.web.ResponseHeaderPolicy.CORS
|
var corsConfig = this.web.ResponseHeaderPolicy.CORS
|
||||||
|
|
||||||
// Allow-Origin
|
// Allow-Origin
|
||||||
@@ -1753,6 +1753,16 @@ func (this *HTTPRequest) processResponseHeaders(responseHeader http.Header, stat
|
|||||||
responseHeader.Set("Access-Control-Max-Age", types.String(corsConfig.MaxAge))
|
responseHeader.Set("Access-Control-Max-Age", types.String(corsConfig.MaxAge))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose-Headers
|
||||||
|
if len(corsConfig.ExposeHeaders) > 0 {
|
||||||
|
responseHeader.Set("Access-Control-Expose-Headers", strings.Join(corsConfig.ExposeHeaders, ", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request-Method
|
||||||
|
if len(corsConfig.RequestMethod) > 0 {
|
||||||
|
responseHeader.Set("Access-Control-Request-Method", strings.ToUpper(corsConfig.RequestMethod))
|
||||||
|
}
|
||||||
|
|
||||||
// Allow-Credentials
|
// Allow-Credentials
|
||||||
responseHeader.Set("Access-Control-Allow-Credentials", "true")
|
responseHeader.Set("Access-Control-Allow-Credentials", "true")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user