This commit is contained in:
@@ -75,16 +75,6 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
async redirects() {
|
async redirects() {
|
||||||
return [
|
return [
|
||||||
{
|
|
||||||
source: `${DASHBOARD_BASE_PATH}/:path*`,
|
|
||||||
destination: '/:path*',
|
|
||||||
permanent: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: DASHBOARD_BASE_PATH,
|
|
||||||
destination: '/',
|
|
||||||
permanent: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
source: '/',
|
source: '/',
|
||||||
destination: DASHBOARD_BASE_PATH,
|
destination: DASHBOARD_BASE_PATH,
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ export default function SubscriptionPage() {
|
|||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
if (cancelled) return
|
if (cancelled) return
|
||||||
if (err?.statusCode === 401) {
|
if (err?.statusCode === 401) {
|
||||||
router.replace('/sign-in?redirect=%2Fsubscription')
|
window.location.replace('/dashboard/sign-in?redirect=%2Fdashboard%2Fsubscription')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (err?.statusCode === 403) {
|
if (err?.statusCode === 403) {
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ describe('DashboardAccessGuard route helpers', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('builds sign-in redirects with public dashboard return paths', () => {
|
it('builds sign-in redirects with public dashboard return paths', () => {
|
||||||
expect(buildSignInRedirect('/reservations')).toBe('/sign-in?redirect=%2Fdashboard%2Freservations')
|
expect(buildSignInRedirect('/reservations')).toBe('/dashboard/sign-in?redirect=%2Fdashboard%2Freservations')
|
||||||
expect(buildSignInRedirect('/dashboard/fleet')).toBe('/sign-in?redirect=%2Fdashboard%2Ffleet')
|
expect(buildSignInRedirect('/dashboard/fleet')).toBe('/dashboard/sign-in?redirect=%2Fdashboard%2Ffleet')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('treats subscription as an owner-only recovery route independent of menu registration', () => {
|
it('treats subscription as an owner-only recovery route independent of menu registration', () => {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export function resolveAccessRedirect(currentPath: string, allowedRoutes: string
|
|||||||
export function buildSignInRedirect(currentPath: string) {
|
export function buildSignInRedirect(currentPath: string) {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
params.set('redirect', toPublicDashboardPath(currentPath))
|
params.set('redirect', toPublicDashboardPath(currentPath))
|
||||||
return `/sign-in?${params.toString()}`
|
return `${toPublicDashboardPath('/sign-in')}?${params.toString()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DashboardAccessGuard({ children }: { children: React.ReactNode }) {
|
export default function DashboardAccessGuard({ children }: { children: React.ReactNode }) {
|
||||||
@@ -147,7 +147,7 @@ export default function DashboardAccessGuard({ children }: { children: React.Rea
|
|||||||
|
|
||||||
if (error?.statusCode === 401) {
|
if (error?.statusCode === 401) {
|
||||||
const target = buildSignInRedirect(currentPath)
|
const target = buildSignInRedirect(currentPath)
|
||||||
if (target !== currentPath) router.replace(target)
|
if (target !== toPublicDashboardPath(currentPath)) window.location.replace(target)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,21 @@ import { describe, expect, it } from 'vitest'
|
|||||||
const require = createRequire(import.meta.url)
|
const require = createRequire(import.meta.url)
|
||||||
|
|
||||||
describe('dashboard next config', () => {
|
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 () => {
|
it('allows generated static media assets to be loaded across local app origins', async () => {
|
||||||
const nextConfig = require('../next.config.js')
|
const nextConfig = require('../next.config.js')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user