diff --git a/.env.development b/.env.development index eec76ed..5d5953f 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ -BASE_URL=/ +BASE_URL=/problemi/ DATABASE_PATH=db.local.json \ No newline at end of file diff --git a/client/App.tsx b/client/App.tsx index 645d360..7280eeb 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -30,7 +30,7 @@ import { UserPage } from './pages/UserPage' export const App = ({ url }: { url?: string }) => { // during server side rendering don't prepend the BASE_URL - const pbu = useContext(ServerContext) ? (s: string) => s : prependBaseUrl + const pbu = prependBaseUrl const handleRouteChange = () => { // @ts-ignore diff --git a/server.ts b/server.ts index e21118a..1928e11 100644 --- a/server.ts +++ b/server.ts @@ -98,8 +98,8 @@ async function createProductionRouter(db: DatabaseConnection) { res.send(finalHtml) } - r.get('/', handleSSR) - r.use('/', express.static('dist/entry-client')) + r.get(process.env.BASE_URL ?? '/', handleSSR) + r.use(process.env.BASE_URL ?? '/', express.static('dist/entry-client')) r.use('*', handleSSR) @@ -113,12 +113,12 @@ async function main() { const [r, db] = await createApiRouter() - app.use('/', r) + app.use(process.env.BASE_URL ?? '/', r) if (config.isDevelopment) { - app.use('/', await createDevRouter(db)) + app.use(process.env.BASE_URL ?? '/', await createDevRouter(db)) } else { - app.use('/', await createProductionRouter(db)) + app.use(process.env.BASE_URL ?? '/', await createProductionRouter(db)) } app.listen(config.port, () => {