diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-02-10 00:14:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-09 11:14:45 -0500 |
commit | cef8f50286ce1bc04c2e5989998d5a0774870de7 (patch) | |
tree | 35caaaf535fd7c03ffde727698a4cef48d854570 /web_src | |
parent | e253888a0e68d03da0616930427d7162eefa6aaf (diff) | |
download | gitea-cef8f50286ce1bc04c2e5989998d5a0774870de7.tar.gz gitea-cef8f50286ce1bc04c2e5989998d5a0774870de7.zip |
Improve AppUrl/ROOT_URL checking (#22836)
After some PRs:
* #21986
* #22795
* #22808
* #22831
* #22839
Users won't be affected by the ROOT_URL problem in most cases. Close
#19345
This PR improves AppUrl/ROOT_URL checking, only check it on the admin
page, and the message is also updated.
Feel free to suggest about more English-native messages.
![image](https://user-images.githubusercontent.com/2114189/217811809-7d44ddb7-2c4a-46d0-a5db-8ae6ee65f8c3.png)
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/features/admin/common.js | 7 | ||||
-rw-r--r-- | web_src/js/features/common-global.js | 7 | ||||
-rw-r--r-- | web_src/js/index.js | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/web_src/js/features/admin/common.js b/web_src/js/features/admin/common.js index 2438fcf62b..d0b3e461d5 100644 --- a/web_src/js/features/admin/common.js +++ b/web_src/js/features/admin/common.js @@ -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 () { diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index 4677eeac0c..e655feec0b 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -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.`); } diff --git a/web_src/js/index.js b/web_src/js/index.js index 74d80776b5..611c09d2b8 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -48,7 +48,6 @@ import { initCommitStatuses, } from './features/repo-commit.js'; import { - checkAppUrl, initFootLanguageMenu, initGlobalButtonClickOnEnter, initGlobalButtons, @@ -199,5 +198,4 @@ $(document).ready(() => { initUserAuthWebAuthnRegister(); initUserSettings(); initViewedCheckboxListenerFor(); - checkAppUrl(); }); |