import type { NextConfig } from "next"; const subDomain = process.env.NEXT_PUBLIC_SUB_DOMAIN || "http://localhost:13000"; const webhwpCtrlBase = ( process.env.NEXT_PUBLIC_WEBHYP_CTRL_URL || "https://hwp.onasys.co.kr/webhwpctrl" ).replace(/\/$/, ""); const webhwpAssetPrefixes = ["js", "hwpsdk", "dist", "commonFrame", "wasm"] as const; const nextConfig: NextConfig = { output: "standalone", reactStrictMode: true, transpilePackages: ["@common/assets"], experimental: { globalNotFound: true, }, async rewrites() { return { beforeFiles: [ { source: "/_next/static/:path*", destination: `${subDomain}/_next/static/:path*`, has: [ { type: "header", key: "referer", value: "(.*)/cms(.*)", }, ], }, ], afterFiles: [ { source: "/cms/:path*", destination: `${subDomain}/cms/:path*`, }, ...webhwpAssetPrefixes.map((prefix) => ({ source: `/webhwpctrl/${prefix}/:path*`, destination: `${webhwpCtrlBase}/${prefix}/:path*`, })), { source: "/webhwpctrl/file/:path*", destination: `${webhwpCtrlBase}/file/:path*`, }, ], fallback: [], }; }, }; export default nextConfig;