From 3cb84c69c08974c150c04f1911ea9128ca4fed07 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Wed, 23 Nov 2022 23:45:37 +0100 Subject: [PATCH] fix: Preact router and BASE_URL --- client/App.tsx | 17 +++++++++++------ client/entry-server.tsx | 6 +++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/client/App.tsx b/client/App.tsx index 2d67f83..30be7dc 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -1,6 +1,8 @@ import Router from 'preact-router' import { route } from 'preact-router' -import { useEffect } from 'preact/hooks' +import { useContext, useEffect } from 'preact/hooks' +import { prependBaseUrl } from './api' +import { ServerContext } from './hooks' import { AdminPage } from './pages/Admin' import { HomePage } from './pages/Home' @@ -21,27 +23,30 @@ const Redirect = ({ to }: { to: string }) => { } export const App = ({ url }: { url?: string }) => { + // during server side rendering don't prepend the BASE_URL + const pbu = useContext(ServerContext) ? (s: string) => s : prependBaseUrl + return ( { const html = renderToString( - {/* */} - - {/* */} + + + )