Skip to content

Don't use sub-path twice for manifest #14427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 33 additions & 27 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,33 @@ var (
AppWorkPath string

// Server settings
Protocol Scheme
Domain string
HTTPAddr string
HTTPPort string
LocalURL string
RedirectOtherPort bool
PortToRedirect string
OfflineMode bool
CertFile string
KeyFile string
StaticRootPath string
StaticCacheTime time.Duration
EnableGzip bool
LandingPageURL LandingPage
UnixSocketPermission uint32
EnablePprof bool
PprofDataPath string
EnableLetsEncrypt bool
LetsEncryptTOS bool
LetsEncryptDirectory string
LetsEncryptEmail string
GracefulRestartable bool
GracefulHammerTime time.Duration
StartupTimeout time.Duration
StaticURLPrefix string
AbsoluteAssetURL string
Protocol Scheme
Domain string
HTTPAddr string
HTTPPort string
LocalURL string
RedirectOtherPort bool
PortToRedirect string
OfflineMode bool
CertFile string
KeyFile string
StaticRootPath string
StaticCacheTime time.Duration
EnableGzip bool
LandingPageURL LandingPage
UnixSocketPermission uint32
EnablePprof bool
PprofDataPath string
EnableLetsEncrypt bool
LetsEncryptTOS bool
LetsEncryptDirectory string
LetsEncryptEmail string
GracefulRestartable bool
GracefulHammerTime time.Duration
StartupTimeout time.Duration
StaticURLPrefix string
StaticURLPrefixManifest string
Copy link
Member

@6543 6543 Jan 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, adding a special var only for manifest is the right way to fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to change it! I do not know anything about go and my heart isn't connected with this pull request. All I know is that it fixes the issue for me. And I know it is not very nicely done. So: You surely don't offend me if you fix it differently

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First thanks for the pull, I think we can evolve your pull ;) together ...

AbsoluteAssetURL string

SSH = struct {
Disabled bool `ini:"DISABLE_SSH"`
Expand Down Expand Up @@ -606,6 +607,11 @@ 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, "/")
// FIXME: Why does the content of 'StaticURLPrefixManifest' depend on the ordering of
// the next two lines?
// Manifest on top: ""
// Manifest below: "/gitea"
StaticURLPrefixManifest = strings.TrimSuffix(sec.Key("STATIC_URL_PREFIX").MustString(""), "/")
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
Expand All @@ -614,7 +620,7 @@ func NewContext() {
Domain = urlHostname
}

AbsoluteAssetURL = MakeAbsoluteAssetURL(AppURL, StaticURLPrefix)
AbsoluteAssetURL = MakeAbsoluteAssetURL(AppURL, StaticURLPrefixManifest)

manifestBytes := MakeManifestData(AppName, AppURL, AbsoluteAssetURL)
ManifestData = `application/json;base64,` + base64.StdEncoding.EncodeToString(manifestBytes)
Expand Down