Update next config to support supabase url

This commit is contained in:
Nate Kelley 2025-08-11 16:41:11 -06:00
parent d8451325cc
commit 2fee9a2311
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,15 @@ const apiUrl = new URL(env.NEXT_PUBLIC_API_URL).origin;
const api2Url = new URL(env.NEXT_PUBLIC_API2_URL).origin;
const profilePictureURL = 'https://googleusercontent.com';
// Derive Supabase origins (HTTP and WS) from env so CSP allows them in all modes
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseOrigin = supabaseUrl ? new URL(supabaseUrl).origin : '';
const supabaseWsOrigin = supabaseUrl
? supabaseUrl.startsWith('https')
? supabaseOrigin.replace('https', 'wss')
: supabaseOrigin.replace('http', 'ws')
: '';
// Function to create CSP header with dynamic API URLs
const createCspHeader = (isEmbed = false) => {
const isDev = process.env.NODE_ENV === 'development';
@ -42,6 +51,8 @@ const createCspHeader = (isEmbed = false) => {
"'self'",
'data:', // Allow data URLs for PDF exports and other data URI downloads
localDomains,
supabaseOrigin,
supabaseWsOrigin,
'https://*.vercel.app',
'https://*.supabase.co',
'wss://*.supabase.co',