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.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Set CORS allow-origin to CLOUD_URL when API_URL is absolute
Mike Caobfb72a7890f0
diff --git a/next.config.ts b/next.config.tsindex c9c717f94..5498ad8da 100644--- a/next.config.ts+++ b/next.config.ts@@ -40,6 +40,8 @@ function normalizePath(url: string) {}const apiUrlOrigin = getUrlOrigin(apiUrl);+const isAbsoluteApiUrl = Boolean(apiUrlOrigin);+const allowOrigin = isAbsoluteApiUrl && cloudUrl ? cloudUrl : '*';const connectSrc = ["'self'", 'https:', apiUrlOrigin].filter(Boolean).join(' ');const contentSecurityPolicy = `@@ -84,8 +86,14 @@ const trackerHeaders = [const apiHeaders = [{key: 'Access-Control-Allow-Origin',- value: '*',+ value: allowOrigin,},+ ...(allowOrigin !== '*'+ ? [+ { key: 'Access-Control-Allow-Credentials', value: 'true' },+ { key: 'Vary', value: 'Origin' },+ ]+ : []),{key: 'Access-Control-Allow-Headers',value: '*',