wealth/apps/wall-street-plaza/next.config.ts

62 lines
2.5 KiB
TypeScript

import { withFontCopy } from '@lumina/island/tools/font-copy-plugin';
import { withIconSprite } from '@lumina/island/tools/icon-sprite-plugin';
import type { NextConfig } from 'next';
import path from 'node:path';
// Libs compile from source outside the app, so tracing and Turbopack both start at the workspace root.
const workspaceRoot = path.join(__dirname, '../..');
// Fonts and the icon sprite keep fixed names (0011, 0012); Next serves public/ with max-age=0.
const immutable = [
{ key: 'Cache-Control', value: 'public, max-age=31536000, immutable' },
];
// The panel is never framed, never indexed, and never sends full URLs to other sites.
const security = [
{ key: 'Content-Security-Policy', value: "frame-ancestors 'none'" },
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'same-origin' },
{ key: 'X-Robots-Tag', value: 'noindex, nofollow' },
];
// The edge nginx (0001) passes a streamed page on as each part renders instead of buffering it whole.
const streaming = [{ key: 'X-Accel-Buffering', value: 'no' }];
const nextConfig: NextConfig = {
// The image runs .next/standalone/apps/<app>/server.js with only the traced files; it never loads
// this file at runtime, so the plugins below never run in the container.
output: 'standalone',
outputFileTracingRoot: workspaceRoot,
turbopack: { root: workspaceRoot },
poweredByHeader: false,
// Set when the panel shares an origin with the market apps under a path (e.g. `/admin`); empty
// in local dev, where the panel has its own port.
basePath: process.env.NEXT_BASE_PATH ?? '',
// Metadata always in <head> (0054).
htmlLimitedBots: /.*/,
// Workspace packages export TypeScript source, so Next.js compiles them.
transpilePackages: [
'@lumina/garden-roof',
'@lumina/integrations',
'@lumina/island',
'@lumina/libs',
'@lumina/tools',
],
// No service worker or manifest: the panel isn't installable (0062).
async headers() {
return [
{ source: '/:path*', headers: [...security, ...streaming] },
{ source: '/fonts/:path*', headers: immutable },
{ source: '/icons/:path*', headers: immutable },
];
},
async redirects() {
return [{ source: '/', destination: '/health', permanent: false }];
},
};
// On next dev and next build, island's plugins write the fonts and icon sprite into public/
// under their fixed names, with no hash (0012).
export default withIconSprite(withFontCopy(nextConfig));