fix payment customer and dashboard settings
Build & Deploy / Build & Push Docker Image (push) Successful in 12m39s
Test / Type Check (all packages) (push) Successful in 5m8s
Build & Deploy / Deploy to VPS (push) Successful in 7s
Test / API Unit Tests (push) Failing after 4m24s
Test / Homepage Unit Tests (push) Successful in 3m27s
Test / Storefront Unit Tests (push) Successful in 4m48s
Test / Admin Unit Tests (push) Successful in 3m0s
Test / Dashboard Unit Tests (push) Successful in 4m18s
Test / API Integration Tests (push) Failing after 4m34s
Build & Deploy / Build & Push Docker Image (push) Successful in 12m39s
Test / Type Check (all packages) (push) Successful in 5m8s
Build & Deploy / Deploy to VPS (push) Successful in 7s
Test / API Unit Tests (push) Failing after 4m24s
Test / Homepage Unit Tests (push) Successful in 3m27s
Test / Storefront Unit Tests (push) Successful in 4m48s
Test / Admin Unit Tests (push) Successful in 3m0s
Test / Dashboard Unit Tests (push) Successful in 4m18s
Test / API Integration Tests (push) Failing after 4m34s
This commit is contained in:
@@ -4,11 +4,16 @@ import {
|
||||
localeCookie,
|
||||
localeCookieMaxAgeSeconds,
|
||||
localeFromAcceptLanguage,
|
||||
localizedPath,
|
||||
routeIdFromAnyLocaleSlug,
|
||||
routeIdFromSlug,
|
||||
} from '@/lib/localization/config';
|
||||
import { buildContentSecurityPolicy, createNonce } from '@/lib/security/csp';
|
||||
import type { NextRequest } from 'next/server';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const dashboardLanguageCookie = 'rentaldrivego-language';
|
||||
|
||||
function applySecurityHeaders(response: NextResponse, contentSecurityPolicy: string): NextResponse {
|
||||
response.headers.set('Content-Security-Policy', contentSecurityPolicy);
|
||||
response.headers.set('Referrer-Policy', 'strict-origin-when-cross-origin');
|
||||
@@ -73,6 +78,40 @@ export function proxy(request: NextRequest): NextResponse {
|
||||
return applySecurityHeaders(NextResponse.redirect(destination), csp);
|
||||
}
|
||||
|
||||
if (isLocale(firstSegment) && request.nextUrl.pathname === `/${firstSegment}/subscription`) {
|
||||
const destination = request.nextUrl.clone();
|
||||
destination.pathname = '/dashboard/subscription';
|
||||
const response = NextResponse.redirect(destination);
|
||||
response.cookies.set(localeCookie, firstSegment, {
|
||||
path: '/',
|
||||
sameSite: 'lax',
|
||||
maxAge: localeCookieMaxAgeSeconds,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
httpOnly: false,
|
||||
});
|
||||
response.cookies.set(dashboardLanguageCookie, firstSegment, {
|
||||
path: '/',
|
||||
sameSite: 'lax',
|
||||
maxAge: localeCookieMaxAgeSeconds,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
httpOnly: false,
|
||||
});
|
||||
return applySecurityHeaders(response, csp);
|
||||
}
|
||||
|
||||
if (isLocale(firstSegment)) {
|
||||
const segments = request.nextUrl.pathname.split('/').filter(Boolean);
|
||||
const slug = segments.slice(1).join('/');
|
||||
if (slug && !routeIdFromSlug(firstSegment, slug)) {
|
||||
const routeId = routeIdFromAnyLocaleSlug(slug);
|
||||
if (routeId) {
|
||||
const destination = request.nextUrl.clone();
|
||||
destination.pathname = localizedPath(routeId, firstSegment);
|
||||
return applySecurityHeaders(NextResponse.redirect(destination), csp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const response = NextResponse.next({ request: { headers: requestHeaders } });
|
||||
const explicitLocale = request.nextUrl.pathname.split('/')[1];
|
||||
if (isLocale(explicitLocale)) {
|
||||
|
||||
Reference in New Issue
Block a user