44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import type { NextConfig } from "next"
|
|
import { PHASE_DEVELOPMENT_SERVER } from "next/constants"
|
|
|
|
const backendBaseUrl =
|
|
process.env.NEXT_PUBLIC_API_BASE_URL?.trim() || "http://127.0.0.1:8083"
|
|
const productionBasePath = "/widget"
|
|
|
|
export default function nextConfig(phase: string): NextConfig {
|
|
if (phase === PHASE_DEVELOPMENT_SERVER) {
|
|
return {
|
|
reactStrictMode: true,
|
|
trailingSlash: true,
|
|
images: {
|
|
unoptimized: true,
|
|
},
|
|
async rewrites() {
|
|
return [
|
|
{
|
|
source: "/api/:path*",
|
|
destination: `${backendBaseUrl}/api/:path*`,
|
|
basePath: false,
|
|
},
|
|
{
|
|
source: "/storage/:path*",
|
|
destination: `${backendBaseUrl}/storage/:path*`,
|
|
basePath: false,
|
|
},
|
|
]
|
|
},
|
|
}
|
|
}
|
|
|
|
return {
|
|
reactStrictMode: true,
|
|
output: "export",
|
|
basePath: productionBasePath,
|
|
assetPrefix: `${productionBasePath}/`,
|
|
trailingSlash: true,
|
|
images: {
|
|
unoptimized: true,
|
|
},
|
|
}
|
|
}
|