mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-22 10:15:47 +08:00
feat: fix 403 error in CorsFilter
This commit is contained in:
parent
814d3f749b
commit
0096e47351
@ -171,6 +171,14 @@ func getHostname(s string) string {
|
||||
return res
|
||||
}
|
||||
|
||||
func removePort(s string) string {
|
||||
ipStr, _, err := net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
ipStr = s
|
||||
}
|
||||
return ipStr
|
||||
}
|
||||
|
||||
func isHostIntranet(s string) bool {
|
||||
ipStr, _, err := net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
|
@ -44,7 +44,7 @@ func CorsFilter(ctx *context.Context) {
|
||||
origin := ctx.Input.Header(headerOrigin)
|
||||
originConf := conf.GetConfigString("origin")
|
||||
originHostname := getHostname(origin)
|
||||
host := ctx.Request.Host
|
||||
host := removePort(ctx.Request.Host)
|
||||
|
||||
if strings.HasPrefix(origin, "http://localhost") || strings.HasPrefix(origin, "https://localhost") || strings.HasPrefix(origin, "http://127.0.0.1") || strings.HasPrefix(origin, "http://casdoor-app") {
|
||||
setCorsHeaders(ctx, origin)
|
||||
|
Loading…
x
Reference in New Issue
Block a user