mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-22 18:25:47 +08:00
Allow localhost in CorsFilter
This commit is contained in:
parent
577bf91d25
commit
a8e541159b
@ -16,6 +16,7 @@ package routers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/beego/beego/context"
|
"github.com/beego/beego/context"
|
||||||
"github.com/casdoor/casdoor/conf"
|
"github.com/casdoor/casdoor/conf"
|
||||||
@ -39,6 +40,11 @@ func CorsFilter(ctx *context.Context) {
|
|||||||
origin := ctx.Input.Header(headerOrigin)
|
origin := ctx.Input.Header(headerOrigin)
|
||||||
originConf := conf.GetConfigString("origin")
|
originConf := conf.GetConfigString("origin")
|
||||||
|
|
||||||
|
if strings.HasPrefix(origin, "http://localhost") {
|
||||||
|
setCorsHeaders(ctx, origin)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.Request.Method == "POST" && ctx.Request.RequestURI == "/api/login/oauth/access_token" {
|
if ctx.Request.Method == "POST" && ctx.Request.RequestURI == "/api/login/oauth/access_token" {
|
||||||
setCorsHeaders(ctx, origin)
|
setCorsHeaders(ctx, origin)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user