Skip to content
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

Skip frontend ROOT_URL check on installation page, remove unnecessary global var #19291

Merged
merged 2 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 7 additions & 9 deletions routers/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@ const (
tplPostInstall base.TplName = "post-install"
)

var supportedDbTypeNames []map[string]string // use a slice to keep order
func getDbTypeNames() []map[string]string {
if supportedDbTypeNames == nil {
for _, t := range setting.SupportedDatabaseTypes {
supportedDbTypeNames = append(supportedDbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]})
}
// getSupportedDbTypeNames returns a slice for supported database types and names. The slice is used to keep the order
func getSupportedDbTypeNames() (dbTypeNames []map[string]string) {
for _, t := range setting.SupportedDatabaseTypes {
dbTypeNames = append(dbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]})
}
return supportedDbTypeNames
return dbTypeNames
}

// Init prepare for rendering installation page
func Init(next http.Handler) http.Handler {
rnd := templates.HTMLRenderer()

dbTypeNames := getSupportedDbTypeNames()
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
if setting.InstallLock {
resp.Header().Add("Refresh", "1; url="+setting.AppURL+"user/login")
Expand All @@ -74,7 +72,7 @@ func Init(next http.Handler) http.Handler {
"i18n": locale,
"Title": locale.Tr("install.install"),
"PageIsInstall": true,
"DbTypeNames": getDbTypeNames(),
"DbTypeNames": dbTypeNames,
"AllLangs": translation.AllLangs(),
"PageStartTime": startTime,

Expand Down
3 changes: 3 additions & 0 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ export function checkAppUrl() {
if (curUrl.startsWith(appUrl)) {
return;
}
if (document.querySelector('.page-content.install')) {
return; // no need to show the message on the installation page
}
showGlobalErrorMessage(`Your ROOT_URL in app.ini is ${appUrl} but you are visiting ${curUrl}
You should set ROOT_URL correctly, otherwise the web may not work correctly.`);
}