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

Improve AppUrl/ROOT_URL checking #22836

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
improve
  • Loading branch information
wxiaoguang committed Feb 9, 2023
commit 58476c98a50b0259ba27547f20d6a396cf135cd4
7 changes: 6 additions & 1 deletion web_src/js/features/admin/common.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import $ from 'jquery';
import {checkAppUrl} from '../common-global.js';

const {csrfToken} = window.config;

export function initAdminCommon() {
if ($('.admin').length === 0) {
if ($('.page-content.admin').length === 0) {
return;
}

// check whether appUrl(ROOT_URL) is correct, if not, show an error message
// only admin pages need this check because most templates are using relative URLs now
checkAppUrl();

// New user
if ($('.admin.new.user').length > 0 || $('.admin.edit.user').length > 0) {
$('#login_type').on('change', function () {
Expand Down
7 changes: 2 additions & 5 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,6 @@ export function checkAppUrl() {
if (curUrl.startsWith(appUrl) || `${curUrl}/` === 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.`);
showGlobalErrorMessage(`Your ROOT_URL in app.ini is "${appUrl}", it's unlikely matching the site you are visiting.
Mismatched ROOT_URL config causes wrong URL links for web UI/mail content/webhook notification.`);
}
2 changes: 0 additions & 2 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import {
initCommitStatuses,
} from './features/repo-commit.js';
import {
checkAppUrl,
initFootLanguageMenu,
initGlobalButtonClickOnEnter,
initGlobalButtons,
Expand Down Expand Up @@ -199,5 +198,4 @@ $(document).ready(() => {
initUserAuthWebAuthnRegister();
initUserSettings();
initViewedCheckboxListenerFor();
checkAppUrl();
});