Update vite.config.ts
Sécurité build Netlify
This commit is contained in:
1 parent
459e93d314
commit
6acdd39563
1 file changed
+4
@@ -66,6 +66,10 @@ function contentSecurityPolicy(supabaseUrl: string): Plugin {
|
||||
// remplace base: '/' par base: '/azuucine/'.
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, '.', 'VITE_')
|
||||
// Sur Netlify, un build sans Supabase donnerait un site « sans compte » (données invisibles) : on refuse.
|
||||
if (loadEnv(mode, '.', '').NETLIFY && (!env.VITE_SUPABASE_URL || !env.VITE_SUPABASE_ANON_KEY)) {
|
||||
throw new Error('VITE_SUPABASE_URL / VITE_SUPABASE_ANON_KEY manquantes dans Netlify → Environment variables')
|
||||
}
|
||||
const origin = (env.VITE_SUPABASE_URL ?? '').trim().replace(/^(https?:\/\/[^/]+).*$/, '$1')
|
||||
const supabaseUrl = /^https:\/\/[a-z0-9-]+\.supabase\.(co|in)$/i.test(origin) ? origin : ''
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user