chore: wire Carplace into dev and production stacks
Build & Deploy / Build & Push Docker Image (push) Successful in 2m55s
Test / Type Check (all packages) (push) Successful in 54s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Failing after 48s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Storefront Unit Tests (push) Failing after 40s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Failing after 42s
Test / API Integration Tests (push) Successful in 1m0s
Build & Deploy / Build & Push Docker Image (push) Successful in 2m55s
Test / Type Check (all packages) (push) Successful in 54s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Failing after 48s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Storefront Unit Tests (push) Failing after 40s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Failing after 42s
Test / API Integration Tests (push) Successful in 1m0s
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
NODE_ENV=production
|
||||
DASHBOARD_INTERNAL_URL=http://dashboard:3001
|
||||
ADMIN_INTERNAL_URL=http://admin:3002
|
||||
CARPLACE_INTERNAL_URL=http://carplace:3004
|
||||
@@ -54,17 +54,17 @@ const nextConfig: NextConfig = {
|
||||
process.env.DASHBOARD_INTERNAL_URL ?? 'http://dashboard:3001';
|
||||
const adminOrigin =
|
||||
process.env.ADMIN_INTERNAL_URL ?? 'http://admin:3002';
|
||||
const storefrontOrigin =
|
||||
process.env.STOREFRONT_INTERNAL_URL ?? 'http://storefront:3004';
|
||||
const carplaceOrigin =
|
||||
process.env.CARPLACE_INTERNAL_URL ?? 'http://carplace:3004';
|
||||
|
||||
return [
|
||||
{
|
||||
source: '/storefront',
|
||||
destination: `${storefrontOrigin}`,
|
||||
source: '/carplace',
|
||||
destination: `${carplaceOrigin}`,
|
||||
},
|
||||
{
|
||||
source: '/storefront/:path*',
|
||||
destination: `${storefrontOrigin}/:path*`,
|
||||
source: '/carplace/:path*',
|
||||
destination: `${carplaceOrigin}/:path*`,
|
||||
},
|
||||
{
|
||||
source: '/dashboard',
|
||||
|
||||
@@ -20,7 +20,7 @@ import type { NextRequest } from 'next/server';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const dashboardLanguageCookie = 'rentaldrivego-language';
|
||||
const reservedProxySegments = new Set(['dashboard', 'admin', 'storefront']);
|
||||
const reservedProxySegments = new Set(['dashboard', 'admin', 'carplace']);
|
||||
|
||||
function applySecurityHeaders(response: NextResponse, contentSecurityPolicy: string): NextResponse {
|
||||
response.headers.set('Content-Security-Policy', contentSecurityPolicy);
|
||||
@@ -99,16 +99,6 @@ export function proxy(request: NextRequest): NextResponse {
|
||||
}
|
||||
|
||||
const pathSegments = request.nextUrl.pathname.split('/').filter(Boolean);
|
||||
if (isLocale(pathSegments[0]) && pathSegments[1] === 'storefront') {
|
||||
const destination = request.nextUrl.clone();
|
||||
destination.pathname = `/${pathSegments.slice(1).join('/')}`;
|
||||
return applySecurityHeaders(NextResponse.redirect(destination), csp);
|
||||
}
|
||||
if (isLocale(pathSegments[0]) && isMode(pathSegments[1]) && pathSegments[2] === 'storefront') {
|
||||
const destination = request.nextUrl.clone();
|
||||
destination.pathname = `/${pathSegments.slice(2).join('/')}`;
|
||||
return applySecurityHeaders(NextResponse.redirect(destination), csp);
|
||||
}
|
||||
|
||||
// Redirect locale-less paths (e.g. /sign-in → /en/system/sign-in), but not proxied app paths or files.
|
||||
const firstSegment = request.nextUrl.pathname.split('/')[1];
|
||||
|
||||
@@ -58,26 +58,15 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
describe('homepage proxy app boundaries', () => {
|
||||
it('does not localize storefront proxy paths', async () => {
|
||||
it('does not localize Carplace proxy paths', async () => {
|
||||
const { proxy } = await import('@/proxy');
|
||||
|
||||
const response = runProxy(proxy, request('https://rentaldrivego.ma/storefront/en'));
|
||||
const response = runProxy(proxy, request('https://rentaldrivego.ma/carplace/en'));
|
||||
|
||||
expect(response.kind).toBe('next');
|
||||
expect(nextServer.redirect).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('redirects locale-prefixed storefront paths back to the storefront proxy mount', async () => {
|
||||
const { proxy } = await import('@/proxy');
|
||||
|
||||
const response = runProxy(proxy, request('https://rentaldrivego.ma/en/storefront/en'));
|
||||
|
||||
expect(response).toMatchObject({
|
||||
kind: 'redirect',
|
||||
url: 'https://rentaldrivego.ma/storefront/en',
|
||||
});
|
||||
});
|
||||
|
||||
it('redirects the root path to locale and mode segments', async () => {
|
||||
const { proxy } = await import('@/proxy');
|
||||
|
||||
@@ -102,17 +91,4 @@ describe('homepage proxy app boundaries', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('redirects locale-and-mode storefront paths back to the storefront proxy mount', async () => {
|
||||
const { proxy } = await import('@/proxy');
|
||||
|
||||
const response = runProxy(
|
||||
proxy,
|
||||
request('https://rentaldrivego.ma/en/dark/storefront/en'),
|
||||
);
|
||||
|
||||
expect(response).toMatchObject({
|
||||
kind: 'redirect',
|
||||
url: 'https://rentaldrivego.ma/storefront/en',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user