import type { NextConfig } from "next"; import { networkInterfaces } from "os"; const getLocalIPs = () => { const ips: string[] = ["localhost", "127.0.0.1"]; const nets = networkInterfaces(); for (const name of Object.keys(nets)) { for (const net of nets[name] || []) { if (net.family === "IPv4" && !net.internal) { ips.push(net.address); } } } return ips; }; const nextConfig: NextConfig = { allowedDevOrigins: getLocalIPs(), async headers() { return [ { source: "/api/:path*", headers: [ { key: "Access-Control-Allow-Origin", value: "*" }, { key: "Access-Control-Allow-Methods", value: "GET,POST,PUT,DELETE,OPTIONS" }, { key: "Access-Control-Allow-Headers", value: "Content-Type, Authorization" }, ], }, ]; }, }; export default nextConfig;