spb/datacenterindex
Public
HTML 53.9%
TypeScript 44.5%
JavaScript 0.6%
SQL 0.5%
1import type { NextConfig } from "next";2import { existsSync } from "node:fs";3import { resolve } from "node:path";45// Local dev convenience: pick up the monorepo root .env (NEXT_PUBLIC_API_URL, NEXT_PUBLIC_SITE_URL)6// without duplicating it under apps/web. Existing process.env values win.7for (const candidate of [resolve(process.cwd(), "../../.env"), resolve(process.cwd(), ".env")]) {8 if (existsSync(candidate)) {9 try {10 const before = { ...process.env };11 process.loadEnvFile(candidate);12 for (const k of Object.keys(before)) if (before[k] !== undefined) process.env[k] = before[k];13 } catch {14 /* ignore */15 }16 }17}1819const nextConfig: NextConfig = {20 reactStrictMode: true,21 agentRules: false,22 poweredByHeader: false,23 transpilePackages: ["@dci/core"],24 images: { unoptimized: false, formats: ["image/avif", "image/webp"] },25 // @dci/core is consumed from TypeScript source with NodeNext-style "./x.js" specifiers; webpack maps26 // them back to .ts via extensionAlias. Client bundles get the "browser" export condition27 // (packages/core/src/index.browser.ts — no Node built-ins); tsconfig mirrors it with customConditions.28 webpack(config) {29 config.resolve = config.resolve ?? {};30 config.resolve.extensionAlias = { ...(config.resolve.extensionAlias ?? {}), ".js": [".ts", ".tsx", ".js"], ".mjs": [".mts", ".mjs"] };31 return config;32 },33 async redirects() {34 // short public aliases (spec §85 / §101) → canonical routes35 return [36 { source: "/markets", destination: "/datacenters/markets", permanent: true },37 { source: "/markets/:slug", destination: "/datacenters/markets/:slug", permanent: true },38 { source: "/facilities", destination: "/datacenters", permanent: true },39 { source: "/facilities/:slug", destination: "/datacenters/:slug", permanent: true },40 { source: "/ai", destination: "/ai-infrastructure", permanent: true },41 { source: "/api-docs", destination: "/developers", permanent: true },42 ];43 },44 async headers() {45 return [46 {47 source: "/(.*)",48 headers: [49 { key: "X-Content-Type-Options", value: "nosniff" },50 { key: "X-Frame-Options", value: "DENY" },51 { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },52 { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), interest-cohort=()" },53 { key: "X-DNS-Prefetch-Control", value: "on" },54 { key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },55 ],56 },57 ];58 },59};6061export default nextConfig;62