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:
parent
b9b3637300
commit
9e0f60ebc8
4 changed files with 12 additions and 3 deletions
|
@ -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>
|
||||
);
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
5
packages/console/src/include.d/node.d.ts
vendored
Normal file
5
packages/console/src/include.d/node.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
type Process = {
|
||||
env: Record<string, string>;
|
||||
};
|
||||
|
||||
declare const process: Process;
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue