From cff9ac0df84aad2ad3a3411985c2ddc20e3b4963 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 30 Jul 2018 17:21:57 -0400 Subject: Add siteURL to WS origin check (#9183) * Add siteURL to WS origin check * Handle subpath * Only add site URL if not * --- app/server.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/server.go') diff --git a/app/server.go b/app/server.go index 6b2e244d8..0c579593e 100644 --- a/app/server.go +++ b/app/server.go @@ -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 -- cgit v1.2.3-1-g7c22