0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): set base url when needed (#312)

* fix(console): set base url when needed

* fix(console): replace `a` with `Link`

* refactor(console): update var name
This commit is contained in:
Gao Sun 2022-03-03 15:44:42 +08:00 committed by GitHub
parent b9b3637300
commit 9e0f60ebc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View file

@ -9,6 +9,8 @@ import Sidebar, { getPath, sections } from './components/Sidebar';
import Topbar from './components/Topbar';
import initI18n from './i18n/init';
const isBasenameNeeded = process.env.NODE_ENV !== 'development' || process.env.PORT === '5002';
void initI18n();
const Main = () => {
@ -33,7 +35,7 @@ const Main = () => {
};
const App = () => (
<BrowserRouter>
<BrowserRouter basename={isBasenameNeeded ? '/console' : ''}>
<Main />
</BrowserRouter>
);

View file

@ -1,5 +1,6 @@
import classNames from 'classnames';
import React, { ReactChild } from 'react';
import { Link } from 'react-router-dom';
import { getPath } from '../../utils';
import * as styles from './index.module.scss';
@ -12,10 +13,10 @@ type Props = {
const Item = ({ icon, title, isActive = false }: Props) => {
return (
<a href={getPath(title)} className={classNames(styles.row, isActive && styles.active)}>
<Link to={getPath(title)} className={classNames(styles.row, isActive && styles.active)}>
{icon && <div className={styles.icon}>{icon}</div>}
<div className={styles.title}>{title}</div>
</a>
</Link>
);
};

View file

@ -0,0 +1,5 @@
type Process = {
env: Record<string, string>;
};
declare const process: Process;

View file

@ -39,6 +39,7 @@ export default function koaSpaProxy<StateT, ContextT extends IRouterParamContext
// Route has been handled by one of mounted apps
if (
!prefix &&
Object.values(MountedApps).some((app) => app !== prefix && requestPath.startsWith(`/${app}`))
) {
return next();