aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-05-10 20:07:01 +0800
committerGitHub <noreply@github.com>2024-05-10 20:07:01 +0800
commit7424f27cf30065a1308aa3ba4d75ea82c0af4af9 (patch)
tree3fd5ab5670c1e13a6c6d1e030b9ab5d75b86f9c9 /web_src/js/features
parentb9396a9b852e4fea0e2c39ef3ef2fdfbc9ea248a (diff)
downloadgitea-7424f27cf30065a1308aa3ba4d75ea82c0af4af9.tar.gz
gitea-7424f27cf30065a1308aa3ba4d75ea82c0af4af9.zip
Check if reverse proxy is correctly configured (#30890)
Follow #27011 Follow #30885 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/admin/selfcheck.js31
-rw-r--r--web_src/js/features/common-global.js2
2 files changed, 32 insertions, 1 deletions
diff --git a/web_src/js/features/admin/selfcheck.js b/web_src/js/features/admin/selfcheck.js
new file mode 100644
index 0000000000..699395b363
--- /dev/null
+++ b/web_src/js/features/admin/selfcheck.js
@@ -0,0 +1,31 @@
+import {toggleElem} from '../../utils/dom.js';
+import {POST} from '../../modules/fetch.js';
+
+const {appSubUrl} = window.config;
+
+export async function initAdminSelfCheck() {
+ const elCheckByFrontend = document.querySelector('#self-check-by-frontend');
+ if (!elCheckByFrontend) return;
+
+ const elContent = document.querySelector('.page-content.admin .admin-setting-content');
+
+ // send frontend self-check request
+ const resp = await POST(`${appSubUrl}/admin/self_check`, {
+ data: new URLSearchParams({
+ location_origin: window.location.origin,
+ now: Date.now(), // TODO: check time difference between server and client
+ }),
+ });
+ const json = await resp.json();
+ toggleElem(elCheckByFrontend, Boolean(json.problems?.length));
+ for (const problem of json.problems ?? []) {
+ const elProblem = document.createElement('div');
+ elProblem.classList.add('ui', 'warning', 'message');
+ elProblem.textContent = problem;
+ elCheckByFrontend.append(elProblem);
+ }
+
+ // only show the "no problem" if there is no visible "self-check-problem"
+ const hasProblem = Boolean(elContent.querySelectorAll('.self-check-problem:not(.tw-hidden)').length);
+ toggleElem(elContent.querySelector('.self-check-no-problem'), !hasProblem);
+}
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index 5b8673105d..3b021d4485 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -451,5 +451,5 @@ export function checkAppUrl() {
return;
}
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/OAuth2 sign-in.`);
+Mismatched ROOT_URL config causes wrong URL links for web UI/mail content/webhook notification/OAuth2 sign-in.`, 'warning');
}