diff --git a/examples/tanstack-router-simple/src/routes/redirect.tsx b/examples/tanstack-router-simple/src/routes/redirect.tsx index 65f765f..c1593a6 100644 --- a/examples/tanstack-router-simple/src/routes/redirect.tsx +++ b/examples/tanstack-router-simple/src/routes/redirect.tsx @@ -26,13 +26,17 @@ function RedirectComponent() { well on first load when relevant.
-NOTE: the server side of things doesn't seem to be working atm. Could be an issue in tanstack router.
-- - Redirect + + Client Side Redirect
+ + ); } diff --git a/examples/tanstack-router-simple/src/server.ts b/examples/tanstack-router-simple/src/server.ts index e9a205b..72f8362 100644 --- a/examples/tanstack-router-simple/src/server.ts +++ b/examples/tanstack-router-simple/src/server.ts @@ -17,6 +17,11 @@ const server = new Hono() try { const { app, router } = await entry.render(c.req.raw); + // Handle redirects + if (router.state.redirect) { + return c.redirect(router.state.redirect.href); + } + const { stream, statusCode } = await renderToStream({ app: () => app, req: c.req.raw, @@ -39,7 +44,7 @@ const server = new Hono() let status = statusCode(); - // Handle redirects + // Handle 404 errors if (router.hasNotFoundMatch() && status !== 500) status = 404; return new Response(stream, { status, headers: { 'Content-Type': 'text/html' } });