mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-22 18:25:47 +08:00
feat: allow CORS for 127.0.0.1
This commit is contained in:
parent
06e3b8481f
commit
5c89705d9e
@ -428,7 +428,7 @@ func (application *Application) GetId() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (application *Application) IsRedirectUriValid(redirectUri string) bool {
|
func (application *Application) IsRedirectUriValid(redirectUri string) bool {
|
||||||
redirectUris := append([]string{"http://localhost:"}, application.RedirectUris...)
|
redirectUris := append([]string{"http://localhost:", "http://127.0.0.1:"}, application.RedirectUris...)
|
||||||
for _, targetUri := range redirectUris {
|
for _, targetUri := range redirectUris {
|
||||||
targetUriRegex := regexp.MustCompile(targetUri)
|
targetUriRegex := regexp.MustCompile(targetUri)
|
||||||
if targetUriRegex.MatchString(redirectUri) || strings.Contains(redirectUri, targetUri) {
|
if targetUriRegex.MatchString(redirectUri) || strings.Contains(redirectUri, targetUri) {
|
||||||
|
@ -57,7 +57,7 @@ func CorsFilter(ctx *context.Context) {
|
|||||||
originHostname := getHostname(origin)
|
originHostname := getHostname(origin)
|
||||||
host := ctx.Request.Host
|
host := ctx.Request.Host
|
||||||
|
|
||||||
if strings.HasPrefix(origin, "http://localhost") {
|
if strings.HasPrefix(origin, "http://localhost") || strings.HasPrefix(origin, "http://127.0.0.1") {
|
||||||
setCorsHeaders(ctx, origin)
|
setCorsHeaders(ctx, origin)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user