Search code examples
next.jsvercelsupabase

NextJs + supabase not deploying supabaseUrl is required


i'm trying to deploy my project but i keep getting this error saying that supabaseUrl is required.

I'm getting this error enter image description here

This is my supabaseClient.js

import { createClient } from "@supabase/supabase-js";

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;

export const supabase = createClient(supabaseUrl, supabaseAnonKey);

And this is my .env.local file

NEXT_PUBLIC_SUPABASE_URL=https://uee...
NEXT_PUBLIC_SUPABASE_ANON_KEY=ey...VU
NEXT_PUBLIC_CLIENT_ID=75...09
NEXT_PUBLIC_CLIENT_SECRET=46...a
REDIRECT_URI=http://localhost:3000

When i run vercel build and then vercel prod --prebuilt it works fine. Also, i added the supabaseUrl and supabase anon key to the environment variables at project settings in vercel dashboard


Solution

  • Vercel production deployment gets .env variables from .env.production file, also you can manually set up .env variables from settings. enter image description here