- Updated the MeStatusService to include a safe method for fetching residence card verification, improving error handling and providing a fallback response in case of failures. - Refactored the ResidenceCardService to utilize a normalization utility for date handling and improved payload validation, ensuring consistent and safe responses from Salesforce. - Enhanced logging for error scenarios to aid in debugging and maintainability. - Updated the Next.js configuration to allow direct API calls, providing a solution to bypass Next's internal dev proxy and avoid deprecation warnings. - Expanded documentation to guide users on configuring the environment for development.
73 lines
2.3 KiB
JavaScript
73 lines
2.3 KiB
JavaScript
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const workspaceRoot = path.resolve(__dirname, "..", "..");
|
|
|
|
// BFF URL for development API proxying
|
|
const BFF_URL = process.env.BFF_URL || "http://localhost:4000";
|
|
const isDev = process.env.NODE_ENV === "development";
|
|
const directApiBase = process.env.NEXT_PUBLIC_API_BASE;
|
|
const useDirectApiBase = Boolean(directApiBase && directApiBase.trim().startsWith("http"));
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
output: process.env.NODE_ENV === "production" ? "standalone" : undefined,
|
|
|
|
turbopack: {
|
|
resolveAlias: {
|
|
"@customer-portal/domain": path.join(workspaceRoot, "packages/domain/dist"),
|
|
},
|
|
},
|
|
|
|
webpack(config) {
|
|
config.resolve.alias = {
|
|
...config.resolve.alias,
|
|
"@customer-portal/domain": path.join(workspaceRoot, "packages/domain/dist"),
|
|
};
|
|
return config;
|
|
},
|
|
|
|
env: {
|
|
// Default: same-origin (dev rewrites or prod nginx proxy).
|
|
// Optional: set NEXT_PUBLIC_API_BASE (e.g. http://localhost:4000) to bypass Next rewrites and call the BFF directly via CORS.
|
|
NEXT_PUBLIC_API_BASE: process.env.NEXT_PUBLIC_API_BASE ?? "",
|
|
NEXT_PUBLIC_APP_NAME: process.env.NEXT_PUBLIC_APP_NAME,
|
|
NEXT_PUBLIC_APP_VERSION: process.env.NEXT_PUBLIC_APP_VERSION,
|
|
},
|
|
|
|
// Proxy API requests to BFF in development
|
|
async rewrites() {
|
|
if (!isDev) return [];
|
|
// If NEXT_PUBLIC_API_BASE is set, the app will call the BFF directly via CORS.
|
|
// Avoid Next's internal dev proxy path (which can emit Node deprecation warnings).
|
|
if (useDirectApiBase) return [];
|
|
return [
|
|
{
|
|
source: "/api/:path*",
|
|
destination: `${BFF_URL}/api/:path*`,
|
|
},
|
|
];
|
|
},
|
|
|
|
compiler: {
|
|
removeConsole: process.env.NODE_ENV === "production",
|
|
},
|
|
|
|
experimental: {
|
|
optimizePackageImports: ["@heroicons/react", "@tanstack/react-query"],
|
|
},
|
|
|
|
typescript: { ignoreBuildErrors: false },
|
|
};
|
|
|
|
// Only load bundle analyzer when explicitly requested
|
|
let exportedConfig = nextConfig;
|
|
|
|
if (process.env.ANALYZE === "true") {
|
|
const bundleAnalyzer = (await import("@next/bundle-analyzer")).default;
|
|
exportedConfig = bundleAnalyzer({ enabled: true })(nextConfig);
|
|
}
|
|
|
|
export default exportedConfig;
|