Use next rewrites for API_URL.
This commit is contained in:
+20
-11
@@ -123,6 +123,7 @@ if (isProd) {
|
||||
}
|
||||
|
||||
const rewrites = [];
|
||||
const beforeFilesRewrites = [];
|
||||
|
||||
if (trackerScriptURL) {
|
||||
rewrites.push({
|
||||
@@ -157,6 +158,11 @@ if (isRelativeUrl(apiUrl)) {
|
||||
destination: '/api/:path*',
|
||||
});
|
||||
}
|
||||
} else if (apiUrl) {
|
||||
beforeFilesRewrites.push({
|
||||
source: '/api/:path((?!auth(?:/|$)|config(?:/|$)).*)',
|
||||
destination: `${apiUrl.replace(/\/+$/, '')}/:path`,
|
||||
});
|
||||
}
|
||||
|
||||
const redirects = [
|
||||
@@ -244,17 +250,20 @@ export default withNextIntl({
|
||||
return headers;
|
||||
},
|
||||
async rewrites() {
|
||||
return [
|
||||
...rewrites,
|
||||
{
|
||||
source: '/telemetry.js',
|
||||
destination: '/api/scripts/telemetry',
|
||||
},
|
||||
{
|
||||
source: '/teams/:teamId/:path*',
|
||||
destination: '/:path*',
|
||||
},
|
||||
];
|
||||
return {
|
||||
beforeFiles: beforeFilesRewrites,
|
||||
afterFiles: [
|
||||
...rewrites,
|
||||
{
|
||||
source: '/telemetry.js',
|
||||
destination: '/api/scripts/telemetry',
|
||||
},
|
||||
{
|
||||
source: '/teams/:teamId/:path*',
|
||||
destination: '/:path*',
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
async redirects() {
|
||||
return [...redirects];
|
||||
|
||||
Generated
+2
@@ -334,6 +334,8 @@ importers:
|
||||
specifier: ^4.1.6
|
||||
version: 4.1.6(@types/node@25.9.0)(jsdom@29.1.1)(msw@2.14.6(@types/node@25.9.0)(typescript@6.0.3))(vite@8.0.11(@types/node@25.9.0)(esbuild@0.28.0)(jiti@2.7.0)(terser@5.46.1)(tsx@4.22.2))
|
||||
|
||||
dist: {}
|
||||
|
||||
packages:
|
||||
|
||||
'@adobe/css-tools@4.4.4':
|
||||
|
||||
Reference in New Issue
Block a user