68bf9ca610
Build & Deploy / Build & Push Docker Image (push) Successful in 3m16s
Test / Type Check (all packages) (push) Successful in 53s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Successful in 56s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Carplace Unit Tests (push) Successful in 40s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Successful in 41s
Test / API Integration Tests (push) Successful in 1m0s
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
/** @type {import('next').NextConfig} */
|
|
|
|
const { buildSecurityHeaders, normalizeAssetPrefix } = require('../../config/nextSecurityHeaders')
|
|
|
|
const CARPLACE_ASSET_PREFIX = '/carplace'
|
|
// In local development the homepage app serves /carplace from port 3000 while
|
|
// the Carplace dev server runs on port 3004. Emit absolute chunk/HMR URLs so
|
|
// the browser asks the Carplace server for its own assets instead of the
|
|
// homepage server.
|
|
const defaultCarplaceAssetPrefix = process.env.NODE_ENV !== 'production'
|
|
? 'http://localhost:3004'
|
|
: CARPLACE_ASSET_PREFIX
|
|
const carplaceAssetPrefix = normalizeAssetPrefix(
|
|
process.env.CARPLACE_ASSET_PREFIX ?? defaultCarplaceAssetPrefix,
|
|
CARPLACE_ASSET_PREFIX,
|
|
)
|
|
const securityHeaders = buildSecurityHeaders({ assetSources: [carplaceAssetPrefix] })
|
|
|
|
const nextConfig = {
|
|
...(carplaceAssetPrefix ? { assetPrefix: carplaceAssetPrefix } : {}),
|
|
images: {
|
|
remotePatterns: [{ protocol: 'https', hostname: 'res.cloudinary.com' }],
|
|
},
|
|
transpilePackages: ['@rentaldrivego/types'],
|
|
async headers() {
|
|
return [{ source: '/:path*', headers: securityHeaders }]
|
|
},
|
|
async rewrites() {
|
|
const apiOrigin = (process.env.API_INTERNAL_URL ?? process.env.API_URL ?? 'http://api:4000').replace(/\/api\/v1\/?$/, '')
|
|
|
|
return {
|
|
beforeFiles: [
|
|
{ source: '/carplace/api/:path*', destination: `${apiOrigin}/api/:path*` },
|
|
],
|
|
afterFiles: [
|
|
{ source: '/carplace', destination: '/' },
|
|
{ source: '/carplace/:path*', destination: '/:path*' },
|
|
],
|
|
fallback: [],
|
|
}
|
|
},
|
|
}
|
|
|
|
module.exports = nextConfig
|