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.

fix self-hosting auth issue with API_URL missing

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