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.

revert api url changes. exclude auth from API_URL

Francis Cao49563809423a
diff --git a/next.config.ts b/next.config.ts
index 331364ea1..879b2d857 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -160,7 +160,7 @@ if (isRelativeUrl(apiUrl)) {
}
} else if (apiUrl) {
beforeFilesRewrites.push({
- source: '/api/:path((?!config(?:/|$)).*)',
+ source: '/api/:path((?!auth(?:/|$)|config(?:/|$)).*)',
destination: `${apiUrl.replace(/\/+$/, '')}/:path`,
});
}
diff --git a/src/lib/api-url.test.ts b/src/lib/api-url.test.ts
index 521d048c4..5458ae6ce 100644
--- a/src/lib/api-url.test.ts
+++ b/src/lib/api-url.test.ts
@@ -20,13 +20,13 @@ describe('getApiUrl', () => {
).toBe('/analytics/internal-api/websites');
});
- test('uses a relative API_URL for auth routes', () => {
+ test('keeps app routes on the local api path', () => {
expect(
getApiUrl('/auth/verify', {
apiUrl: '/internal-api',
basePath: '/analytics',
}),
- ).toBe('/analytics/internal-api/auth/verify');
+ ).toBe('/analytics/api/auth/verify');
});
test('keeps config routes on the local api path', () => {
diff --git a/src/lib/api-url.ts b/src/lib/api-url.ts
index b97e1b005..7d6e9d74d 100644
--- a/src/lib/api-url.ts
+++ b/src/lib/api-url.ts
@@ -3,7 +3,7 @@ type ApiUrlOptions = {
basePath?: string;
};
-const APP_ROUTE_PATTERNS: RegExp[] = [/^\/config(\/|$)/];
+const APP_ROUTE_PATTERNS: RegExp[] = [/^\/auth(\/|$)/, /^\/config(\/|$)/];
function trimTrailingSlash(value: string) {
return value.replace(/\/+$/, '');