diff --git a/public/assets/boot/ctrl_boot_frontoffice.js b/public/assets/boot/ctrl_boot_frontoffice.js index 717163aa7..7bc5ccd2c 100644 --- a/public/assets/boot/ctrl_boot_frontoffice.js +++ b/public/assets/boot/ctrl_boot_frontoffice.js @@ -21,6 +21,7 @@ export default async function main() { await Promise.all([ // procedure with dependency on config setup_chromecast(), setup_title(), + verify_origin(), ]); window.dispatchEvent(new window.Event("pagechange")); @@ -78,3 +79,21 @@ async function setup_polyfill() { await loadJS(import.meta.url, "../lib/polyfill.js"); } } + +async function verify_origin() { + const origin = window.CONFIG["origin"]; + + // happy path + if (!origin) return; + else if (location.origin === origin) return; + + // non happy path + const u = new URL(origin); + if (u.host === location.host) return; + else if (u.hostname === location.hostname) return; + + setTimeout(() => { + location.href = origin + location.pathname + location.search; + }, 1000); + throw new Error("Redirecting to " + origin); +} diff --git a/public/assets/pages/viewerpage/application_editor.css b/public/assets/pages/viewerpage/application_editor.css index d97c626d4..4f9d24a93 100644 --- a/public/assets/pages/viewerpage/application_editor.css +++ b/public/assets/pages/viewerpage/application_editor.css @@ -50,7 +50,7 @@ /* SEARCH */ .CodeMirror-dialog { - position: fixed; + position: sticky; left: 0; right: 0; background: #525659; @@ -77,6 +77,9 @@ background: transparent; width: 20em; color: white; + font-family: inherit; + padding-left: 5px; + font-size: inherit; } .CodeMirror-dialog button { diff --git a/server/common/config.go b/server/common/config.go index c78b9a4cc..68e12828c 100644 --- a/server/common/config.go +++ b/server/common/config.go @@ -367,6 +367,7 @@ func (this *Configuration) Export() interface{} { AuthMiddleware []string `json:"auth"` Thumbnailer []string `json:"thumbnailer"` EnableChromecast bool `json:"enable_chromecast"` + Origin string `json:"origin"` }{ Editor: this.Get("general.editor").String(), ForkButton: this.Get("general.fork_button").Bool(), @@ -403,6 +404,17 @@ func (this *Configuration) Export() interface{} { return tArray }(), EnableChromecast: this.Get("features.protection.enable_chromecast").Bool(), + Origin: func() string { + host := this.Get("general.host").String() + if host == "" { + return "" + } + scheme := "http://" + if this.Get("general.force_ssl").Bool() { + scheme = "https://" + } + return scheme + host + }(), } }