Files
ember-market-frontend/next.config.mjs
2025-03-10 17:39:37 +00:00

54 lines
1.7 KiB
JavaScript

/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
// Disable Next.js handling of API routes that our Express server will handle
async rewrites() {
return [
{
// Don't rewrite actual Next.js API routes
source: "/api/_next/:path*",
destination: "/api/_next/:path*",
},
{
// Rewrite API requests to be handled by our custom Express server
source: "/api/:path*",
destination: "/api/:path*",
},
];
},
// Make environment variables available to both client and server components
env: {
// For integrated backend, use http://localhost:3000/api
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000/api',
},
// Prevent dynamic URLs from being hard-coded at build time
// This is important for Tor compatibility
experimental: {
// This prevents URLs from being hardcoded at build time
esmExternals: true,
},
// Ensure server components can handle URL objects
serverComponentsExternalPackages: ['next/dist/compiled/path-to-regexp'],
// Allow server-side fetch calls to the local API
serverRuntimeConfig: {
apiUrl: 'http://localhost:3000/api',
},
// Special handling for server components
webpack: (config, { isServer }) => {
if (isServer) {
// Server-side specific config
}
return config;
},
};
export default nextConfig;