NEXT_PUBLIC_* vars are baked at build time and can't change at runtime. Server-side rendering (getInitialProps, getServerSideProps, rewrites) now reads process.env.API_URL at runtime, falling back to the baked NEXT_PUBLIC_API_URL for client-side code. This allows the Docker image to connect to trade-api via Docker DNS while the browser still uses the public URL. Co-Authored-By: Charon <charon@lethean.io>
56 lines
1,017 B
JavaScript
56 lines
1,017 B
JavaScript
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
reactStrictMode: true,
|
|
transpilePackages: [
|
|
'antd',
|
|
'rc-util',
|
|
'rc-pagination',
|
|
'rc-picker',
|
|
'rc-input',
|
|
'rc-table',
|
|
'rc-select',
|
|
'rc-tree',
|
|
'rc-dropdown',
|
|
'rc-menu',
|
|
'rc-tabs',
|
|
'rc-tooltip',
|
|
'rc-notification',
|
|
'@ant-design/icons',
|
|
'@ant-design/cssinjs',
|
|
],
|
|
async redirects() {
|
|
return [
|
|
{
|
|
source: '/',
|
|
destination: '/dex',
|
|
permanent: false,
|
|
},
|
|
];
|
|
},
|
|
webpack: (config) => {
|
|
config.module.rules.push({
|
|
test: /\.svg$/i,
|
|
resourceQuery: /url/,
|
|
type: 'asset/resource',
|
|
});
|
|
config.module.rules.push({
|
|
test: /\.svg$/i,
|
|
issuer: /\.[jt]sx?$/,
|
|
resourceQuery: { not: [/url/] },
|
|
use: ['@svgr/webpack'],
|
|
});
|
|
return config;
|
|
},
|
|
async rewrites() {
|
|
const apiUrl =
|
|
process.env.API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3336';
|
|
return [
|
|
{
|
|
source: '/api/:path*',
|
|
destination: `${apiUrl}/api/:path*`,
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|