Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Use next rewrites for API_URL.

Mike Caof985b4f9a559
diff --git a/next.config.ts b/next.config.ts
index 922d128bd..879b2d857 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -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];
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ed0e7f952..5c65e466d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -334,6 +334,8 @@ importers:
specifier: ^4.1.6
+ dist: {}
+
packages: