other
This commit is contained in:
@@ -8,6 +8,46 @@ const nextConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user