File: //workspace/rollout/frontend-next.config.ts.expected
import type { NextConfig } from "next";
function normalizeBasePath(raw: string | undefined): string {
const trimmed = (raw ?? "").trim();
if (!trimmed || trimmed === "/") return "";
const withLeadingSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
return withLeadingSlash.replace(/\/+$/, "");
}
const basePath = normalizeBasePath(process.env.NEXT_PUBLIC_BASE_PATH);
const internalApiUrl = (process.env.INTERNAL_API_URL ?? "")
.trim()
.replace(/\/+$/, "");
const nextConfig: NextConfig = {
// In dev, Next may proxy requests based on the request origin/host.
// Allow common local origins so `next dev --hostname 127.0.0.1` works
// when users access via http://localhost:3000 or http://127.0.0.1:3000.
// Keep the LAN IP as well for dev on the local network.
allowedDevOrigins: ["192.168.1.101", "localhost", "127.0.0.1"],
...(basePath ? { basePath } : {}),
images: {
remotePatterns: [
{
protocol: "https",
hostname: "img.clerk.com",
},
],
},
async headers() {
return [
{
source: "/((?!_next/static|_next/image|favicon.ico).*)",
headers: [
{
key: "Cache-Control",
value: "no-store, no-cache, must-revalidate, max-age=0",
},
],
},
];
},
async rewrites() {
if (!internalApiUrl) return [];
return [
{
source: "/healthz",
destination: `${internalApiUrl}/healthz`,
},
{
source: "/readyz",
destination: `${internalApiUrl}/readyz`,
},
{
source: "/openapi.json",
destination: `${internalApiUrl}/openapi.json`,
},
];
},
};
export default nextConfig;