Files
zitadel/apps/login/next.config.mjs
T
b1c8781516 fix(login): lru-cache compatibility, improve session error handling (#12099)
# Which Problems Are Solved

- Logo and heading overlap on login pages due to a -mb-4 negative margin
on the logo container
- The /login route returns a 500 when `listSessions` fails (e.g. stale
session cookies), because loadSessions has no error handling.
- The proxy logs `"fetch() returned undefined"` because
`fetchIframeOrigins` returns undefined, which lru-cache's forceFetch
treats as a fetch failure.

# How the Problems Are Solved

- Remove `-mb-4` from the logo container in DynamicTheme.
- Wrap `loadSessions` in a try/catch — failures fall through as empty
sessions instead of crashing.
- Return `null` instead of `undefined` from `fetchIframeOrigins` so
lru-cache caches it normally.

---------

Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: conblem <[email protected]>
2026-04-30 15:27:44 +02:00

78 lines
2.3 KiB
JavaScript
Executable File

import createNextIntlPlugin from "next-intl/plugin";
const withNextIntl = createNextIntlPlugin();
const secureHeaders = [
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
},
{
key: "Referrer-Policy",
value: "origin-when-cross-origin",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
{ key: "X-Frame-Options", value: "deny" },
];
/** @type {import('next').NextConfig} */
const nextConfig = {
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
output: process.env.NEXT_OUTPUT_MODE || undefined,
reactStrictMode: true,
experimental: {
// Add React 19 compatibility optimizations
optimizePackageImports: ["@radix-ui/react-tooltip", "@heroicons/react"],
serverActions: {
...(process.env.SERVER_ACTION_ALLOWED_ORIGINS
? { allowedOrigins: process.env.SERVER_ACTION_ALLOWED_ORIGINS.split(",").map((o) => o.trim()) }
: {}),
},
},
// Packages that must not be bundled by webpack and should remain as external
// requires at runtime. These packages use native modules or have bundling
// incompatibilities. Keep this list in sync with package.json dependencies
// when adding new OpenTelemetry or logging packages.
serverExternalPackages: [
'winston',
'@opentelemetry/api',
'@opentelemetry/api-logs',
'@opentelemetry/sdk-node',
'@opentelemetry/sdk-metrics',
'@opentelemetry/sdk-logs',
'@opentelemetry/exporter-metrics-otlp-http',
'@opentelemetry/exporter-logs-otlp-http',
'@opentelemetry/exporter-prometheus',
'@opentelemetry/resources',
'@opentelemetry/semantic-conventions',
'@opentelemetry/auto-instrumentations-node',
'@opentelemetry/winston-transport',
'@opentelemetry/resource-detector-container',
'@opentelemetry/resource-detector-gcp',
],
// Improve SSR stability - not actually needed for React 19 SSR issues
// onDemandEntries: {
// maxInactiveAge: 25 * 1000,
// pagesBufferLength: 2,
// },
// Better error handling for production builds
poweredByHeader: false,
async headers() {
return [
{
source: "/:path*",
headers: secureHeaders,
},
];
},
};
export default withNextIntl(nextConfig);