From 00629fea95970e99ba5ef05954bbad0804805df6 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 22 Oct 2019 14:11:01 +0200 Subject: [assets] configurable URL for static resources (#7911) * static url * add cors support for static resources * [assets] work on the migration to configurable url for assets Signed-off-by: Jakob Ackermann * [misc] fix whitespace Signed-off-by: Jakob Ackermann * [assets] fix the loading of the manifest.json It is generated dynamically, and as such can not be served by the cdn. Signed-off-by: Jakob Ackermann * Revert "add cors support for static resources" This reverts commit 42f964fd181dbb8b139808b9be623470d4f0e40f Signed-off-by: Jakob Ackermann * [docs] add the STATIC_URL_PREFIX option Signed-off-by: Jakob Ackermann * [docs] reverse-proxy: nginx: add two setups for STATIC_URL_PREFIX Signed-off-by: Jakob Ackermann * [assets] migrate the url of a new asset to the static url prefix REF: f2a3abc683ad4b2177b7c7c6160a2c0b4316120a Signed-off-by: Jakob Ackermann --- modules/setting/setting.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/setting') diff --git a/modules/setting/setting.go b/modules/setting/setting.go index d05c52fea0..f3dd45d7bf 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -99,6 +99,7 @@ var ( LetsEncryptEmail string GracefulRestartable bool GracefulHammerTime time.Duration + StaticURLPrefix string SSH = struct { Disabled bool `ini:"DISABLE_SSH"` @@ -573,7 +574,7 @@ func NewContext() { defaultAppURL += ":" + HTTPPort } AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL) - AppURL = strings.TrimRight(AppURL, "/") + "/" + AppURL = strings.TrimSuffix(AppURL, "/") + "/" // Check if has app suburl. appURL, err := url.Parse(AppURL) @@ -583,6 +584,7 @@ func NewContext() { // Suburl should start with '/' and end without '/', such as '/{subpath}'. // This value is empty if site does not have sub-url. AppSubURL = strings.TrimSuffix(appURL.Path, "/") + StaticURLPrefix = strings.TrimSuffix(sec.Key("STATIC_URL_PREFIX").MustString(AppSubURL), "/") AppSubURLDepth = strings.Count(AppSubURL, "/") // Check if Domain differs from AppURL domain than update it to AppURL's domain // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8 -- cgit v1.2.3