Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: 404 content cannot show in special pages

shuaif48c207b1468
diff --git a/ui/src/common/constants.ts b/ui/src/common/constants.ts
index ce692b6a..4b448c7e 100644
--- a/ui/src/common/constants.ts
+++ b/ui/src/common/constants.ts
@@ -10,6 +10,18 @@ export const DRAFT_QUESTION_STORAGE_KEY = '_a_dq_';
export const DRAFT_ANSWER_STORAGE_KEY = '_a_da_';
export const DRAFT_TIMESIGH_STORAGE_KEY = '|_a_t_s_|';
+export const IGNORE_PATH_LIST = [
+ '/users/login',
+ '/users/register',
+ '/users/account-recovery',
+ '/users/change-email',
+ '/users/password-reset',
+ '/users/account-activation',
+ '/users/account-activation/success',
+ '/users/account-activation/failed',
+ '/users/confirm-new-email',
+];
+
export const ADMIN_LIST_STATUS = {
// normal;
1: {
diff --git a/ui/src/utils/guard.ts b/ui/src/utils/guard.ts
index aaa563fc..ee90e220 100644
--- a/ui/src/utils/guard.ts
+++ b/ui/src/utils/guard.ts
@@ -63,7 +63,7 @@ export const deriveLoginState = (): TLoginState => {
return ls;
};
-const isIgnoredPath = (ignoredPath: string | string[]) => {
+export const isIgnoredPath = (ignoredPath: string | string[]) => {
if (!Array.isArray(ignoredPath)) {
ignoredPath = [ignoredPath];
}
diff --git a/ui/src/utils/request.ts b/ui/src/utils/request.ts
index df411410..1629175b 100644
--- a/ui/src/utils/request.ts
+++ b/ui/src/utils/request.ts
@@ -3,12 +3,13 @@ import type { AxiosInstance, AxiosRequestConfig, AxiosError } from 'axios';
import { Modal } from '@/components';
import { loggedUserInfoStore, toastStore, notFoundStore } from '@/stores';
-import { LOGGED_TOKEN_STORAGE_KEY } from '@/common/constants';
+import { LOGGED_TOKEN_STORAGE_KEY, IGNORE_PATH_LIST } from '@/common/constants';
import { RouteAlias } from '@/router/alias';
import { getCurrentLang } from '@/utils/localize';
import Storage from './storage';
import { floppyNavigation } from './floppyNavigation';
+import { isIgnoredPath } from './guard';
const baseConfig = {
timeout: 10000,
@@ -106,12 +107,14 @@ class Request {
// 401: Re-login required
if (status === 401) {
// clear userinfo
+ notFoundStore.getState().hide();
loggedUserInfoStore.getState().clear();
floppyNavigation.navigateToLogin();
return Promise.reject(false);
}
if (status === 403) {
// Permission interception
+ notFoundStore.getState().hide();
if (data?.type === 'url_expired') {
// url expired
floppyNavigation.navigate(RouteAlias.activationFailed, () => {
@@ -144,6 +147,9 @@ class Request {
}
if (status === 404 && error.config?.allow404) {
+ if (isIgnoredPath(IGNORE_PATH_LIST)) {
+ return Promise.reject(false);
+ }
notFoundStore.getState().show();
return Promise.reject(false);
}