How to deploy the same site with 2 config and 2 supabase

Hello,

I have a user application with supabase that I deploy on netlify
I had defined my environment variables in netlify:
VITE_SUPABASE_ANON_KEY
VITE_SUPABASE_URL
it works well …

I now want to deploy the admin mode which is currently on electron, also on netlify
and this on two supabase : harvey and pignada

so I created new variables on netlify :

for development

  • VITE_SUPABASE_URL_HARVEY
  • for user mode : VITE_SUPABASE_ANON_KEY_HARVEY
  • for admin mode : VITE_SUPABASE_SERVICE_ROLE_KEY_HARVEY

for production

  • VITE_SUPABASE_URL_PIGNADA
  • for user mode : VITE_SUPABASE_ANON_KEY_PIGNADA
  • for admin mode : VITE_SUPABASE_SERVICE_ROLE_KEY_PIGNADA

i created a netlify.toml file :

[build]
command = “npm run build:netlify”
publish = “dist”

Redirects

[[redirects]]
from = “/harvey/*”
to = “/harvey/index.html”
status = 200

[[redirects]]
from = “/pignada/*”
to = “/pignada/index.html”
status = 200

[[redirects]]
from = “/harvey-admin/*”
to = “/harvey-admin/index.html”
status = 200

[[redirects]]
from = “/pignada-admin/*”
to = “/pignada-admin/index.html”
status = 200

Redirect default

[[redirects]]
from = “/*”
to = “/harvey/index.html”
status = 200

[build.environment]
VITE_SUPABASE_URL = “%SUPABASE_URL_HARVEY%”
VITE_SUPABASE_ANON_KEY = “%SUPABASE_ANON_KEY_HARVEY%”

Configuration by context

[context.admin]
command = “npm run build:harvey-admin && npm run build:pignada-admin”
[context.admin.environment]
VITE_SUPABASE_ANON_KEY = “%SUPABASE_SERVICE_ROLE_HARVEY%”

[context.harvey]
[context.harvey.environment]
VITE_SUPABASE_URL = “%SUPABASE_URL_HARVEY%”
VITE_SUPABASE_ANON_KEY = “%SUPABASE_ANON_KEY_HARVEY%”

[context.pignada]
[context.pignada.environment]
VITE_SUPABASE_URL = “%SUPABASE_URL_PIGNADA%”
VITE_SUPABASE_ANON_KEY = “%SUPABASE_ANON_KEY_PIGNADA%”

but i have the error : :worried:
index-DRA8vgTl.js:85 Uncaught Error: supabaseUrl is required.

what did I forget?

How to deploy the same site with 2 config and two supabase ?

How are you setting the context?

Hi @hrishikesh ,

actually no, I looked in the “Branches and deploy contexts” menu but it only talks about branch.

And for the environment variables I put the same on all the predefined contexts, as I am a free user, I think I can’t create a context

I think you should simply create 2 sites from the same repo and 2 different environment variables.