diff --git a/frontend/src/middleware.ts b/frontend/src/middleware.ts index aa03b18..a5d634b 100644 --- a/frontend/src/middleware.ts +++ b/frontend/src/middleware.ts @@ -38,7 +38,7 @@ export const onRequest = defineMiddleware(async (context, next) => { } if (path === '/setup' || path === '/register') { - return context.redirect('/demo'); + return context.redirect(`/demo?next=${encodeURIComponent(path + url.search)}`); } const isProtected = @@ -58,7 +58,7 @@ export const onRequest = defineMiddleware(async (context, next) => { const unlocked = context.cookies.get(DEMO_COOKIE)?.value === '1'; if (!unlocked) { - return context.redirect('/demo'); + return context.redirect(`/demo?next=${encodeURIComponent(path + url.search)}`); } return next(); diff --git a/frontend/src/pages/demo.astro b/frontend/src/pages/demo.astro index 96f1d52..2c10ef3 100644 --- a/frontend/src/pages/demo.astro +++ b/frontend/src/pages/demo.astro @@ -2,6 +2,10 @@ export const prerender = false; import PublicLayout from '../layouts/PublicLayout.astro'; import { API_BASE } from '../lib/api'; + +const nextParamRaw = Astro.url.searchParams.get('next') || ''; +const nextParam = nextParamRaw.startsWith('/') ? nextParamRaw : ''; +const nextQuery = nextParam ? `&next=${encodeURIComponent(nextParam)}` : ''; --- @@ -15,6 +19,15 @@ import { API_BASE } from '../lib/api';

+ ${nextParam ? ` +
+

+ You were trying to open ${nextParam.replace(/. + Enter the demo to continue. +

+
+ ` : ''} +

Why a Demo Instance?

@@ -200,8 +213,8 @@ import { API_BASE } from '../lib/api'; Use demo accounts to participate.

@@ -738,6 +751,10 @@ import { API_BASE } from '../lib/api';