From 9c526af996ebab34558c5f0ac7dd8397b8f2c500 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 19 Jul 2026 23:20:51 -0400 Subject: [PATCH] fix for bug#6 --- apps/dashboard/next.config.js | 10 ---------- .../src/app/(dashboard)/subscription/page.tsx | 2 +- .../layout/DashboardAccessGuard.boundary.test.ts | 4 ++-- .../components/layout/DashboardAccessGuard.tsx | 4 ++-- apps/dashboard/src/next-config.test.ts | 15 +++++++++++++++ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/apps/dashboard/next.config.js b/apps/dashboard/next.config.js index 5fb1195..de7cd8b 100644 --- a/apps/dashboard/next.config.js +++ b/apps/dashboard/next.config.js @@ -75,16 +75,6 @@ const nextConfig = { }, async redirects() { return [ - { - source: `${DASHBOARD_BASE_PATH}/:path*`, - destination: '/:path*', - permanent: false, - }, - { - source: DASHBOARD_BASE_PATH, - destination: '/', - permanent: false, - }, { source: '/', destination: DASHBOARD_BASE_PATH, diff --git a/apps/dashboard/src/app/(dashboard)/subscription/page.tsx b/apps/dashboard/src/app/(dashboard)/subscription/page.tsx index 2875af7..f475ea6 100644 --- a/apps/dashboard/src/app/(dashboard)/subscription/page.tsx +++ b/apps/dashboard/src/app/(dashboard)/subscription/page.tsx @@ -247,7 +247,7 @@ export default function SubscriptionPage() { .catch((err: any) => { if (cancelled) return if (err?.statusCode === 401) { - router.replace('/sign-in?redirect=%2Fsubscription') + window.location.replace('/dashboard/sign-in?redirect=%2Fdashboard%2Fsubscription') return } if (err?.statusCode === 403) { diff --git a/apps/dashboard/src/components/layout/DashboardAccessGuard.boundary.test.ts b/apps/dashboard/src/components/layout/DashboardAccessGuard.boundary.test.ts index 661f73a..2bf2f96 100644 --- a/apps/dashboard/src/components/layout/DashboardAccessGuard.boundary.test.ts +++ b/apps/dashboard/src/components/layout/DashboardAccessGuard.boundary.test.ts @@ -109,8 +109,8 @@ describe('DashboardAccessGuard route helpers', () => { }) it('builds sign-in redirects with public dashboard return paths', () => { - expect(buildSignInRedirect('/reservations')).toBe('/sign-in?redirect=%2Fdashboard%2Freservations') - expect(buildSignInRedirect('/dashboard/fleet')).toBe('/sign-in?redirect=%2Fdashboard%2Ffleet') + expect(buildSignInRedirect('/reservations')).toBe('/dashboard/sign-in?redirect=%2Fdashboard%2Freservations') + expect(buildSignInRedirect('/dashboard/fleet')).toBe('/dashboard/sign-in?redirect=%2Fdashboard%2Ffleet') }) it('treats subscription as an owner-only recovery route independent of menu registration', () => { diff --git a/apps/dashboard/src/components/layout/DashboardAccessGuard.tsx b/apps/dashboard/src/components/layout/DashboardAccessGuard.tsx index 9df18d2..23bcdfd 100644 --- a/apps/dashboard/src/components/layout/DashboardAccessGuard.tsx +++ b/apps/dashboard/src/components/layout/DashboardAccessGuard.tsx @@ -93,7 +93,7 @@ export function resolveAccessRedirect(currentPath: string, allowedRoutes: string export function buildSignInRedirect(currentPath: string) { const params = new URLSearchParams() params.set('redirect', toPublicDashboardPath(currentPath)) - return `/sign-in?${params.toString()}` + return `${toPublicDashboardPath('/sign-in')}?${params.toString()}` } export default function DashboardAccessGuard({ children }: { children: React.ReactNode }) { @@ -147,7 +147,7 @@ export default function DashboardAccessGuard({ children }: { children: React.Rea if (error?.statusCode === 401) { const target = buildSignInRedirect(currentPath) - if (target !== currentPath) router.replace(target) + if (target !== toPublicDashboardPath(currentPath)) window.location.replace(target) return } diff --git a/apps/dashboard/src/next-config.test.ts b/apps/dashboard/src/next-config.test.ts index 33ac6f5..a2d4ccc 100644 --- a/apps/dashboard/src/next-config.test.ts +++ b/apps/dashboard/src/next-config.test.ts @@ -5,6 +5,21 @@ import { describe, expect, it } from 'vitest' const require = createRequire(import.meta.url) describe('dashboard next config', () => { + it('keeps the public dashboard base path canonical after login', async () => { + const nextConfig = require('../next.config.js') + + const redirects = await nextConfig.redirects() + + expect(redirects).toEqual([ + { + source: '/', + destination: '/dashboard', + permanent: false, + basePath: false, + }, + ]) + }) + it('allows generated static media assets to be loaded across local app origins', async () => { const nextConfig = require('../next.config.js')