mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 08:36:37 +08:00
fix(frontend): keep browser API on same-origin rewrites in dev
Document that NEXT_PUBLIC_WAVELET_BACKEND_URL must stay unset for local next dev so axios hits /api/* and Next rewrites proxy to the backend.
This commit is contained in:
@@ -4,9 +4,11 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { useEffect } from 'react';
|
||||
import { ConfigService } from '@/lib/services/config';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
export function SiteTitleUpdater() {
|
||||
const pathname = usePathname();
|
||||
const t = useTranslations('providers.titleUpdater');
|
||||
const publicConfigQuery = useQuery({
|
||||
queryKey: ['public-config'],
|
||||
queryFn: () => ConfigService.getPublicConfig(),
|
||||
@@ -18,19 +20,19 @@ export function SiteTitleUpdater() {
|
||||
// Determine the page suffix based on path
|
||||
let suffix = '';
|
||||
if (pathname === '/login') {
|
||||
suffix = ' - 登录';
|
||||
suffix = ` - ${t('login')}`;
|
||||
} else if (pathname === '/register') {
|
||||
suffix = ' - 注册';
|
||||
suffix = ` - ${t('register')}`;
|
||||
} else if (pathname.startsWith('/admin')) {
|
||||
suffix = ' - 后台管理';
|
||||
suffix = ` - ${t('admin')}`;
|
||||
} else if (pathname === '/home') {
|
||||
suffix = ' - 控制台';
|
||||
suffix = ` - ${t('dashboard')}`;
|
||||
} else if (pathname === '/') {
|
||||
suffix = '';
|
||||
}
|
||||
|
||||
document.title = `${siteName}${suffix}`;
|
||||
}, [publicConfigQuery.data?.site_name, pathname]);
|
||||
}, [publicConfigQuery.data?.site_name, pathname, t]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user