Add siteURL to WS origin check (#9183)
* Add siteURL to WS origin check * Handle subpath * Only add site URL if not *
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
de1ce2373d
Коммит
cff9ac0df8
@@ -11,6 +11,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -248,6 +249,14 @@ func (a *App) StopServer() {
|
||||
|
||||
func (a *App) OriginChecker() func(*http.Request) bool {
|
||||
if allowed := *a.Config().ServiceSettings.AllowCorsFrom; allowed != "" {
|
||||
if allowed != "*" {
|
||||
siteURL, err := url.Parse(*a.Config().ServiceSettings.SiteURL)
|
||||
if err == nil {
|
||||
siteURL.Path = ""
|
||||
allowed += " " + siteURL.String()
|
||||
}
|
||||
}
|
||||
|
||||
return utils.OriginChecker(allowed)
|
||||
}
|
||||
return nil
|
||||
|
||||
Ссылка в новой задаче
Block a user