Next.js Discord

Discord Forum

Missing environment variables when deploy to Vercel

Answered
Burmese posted this in #help-forum
Open in Discord
BurmeseOP
I'm using a Supabase connection to get environment variable to Vercel. I have an api route I wrote in /api/signup:

import { createClient } from '@supabase/supabase-js'
import { NextRequest, NextResponse } from "next/server";

// Service role is need for my requirements
  const supabase = createClient(
   process.env.SUPABASE_URL!,
   process.env.SUPABASE_SERVICE_ROLE_KEY!
  );
export async function POST(request: NextRequest) {
    // do signup thing...
}


I did ran build on my side and its working fine, however it returns error when deploying to Vercel:
   Checking validity of types ...
   Collecting page data ...
Error: supabaseUrl is required.
    at new aE (.next/server/chunks/6345.js:6:70841)
    at aA (.next/server/chunks/6345.js:6:74729)
    at 81811 (.next/server/app/api/signup/route.js:1:1462)
    at t (.next/server/webpack-runtime.js:1:128)
    at s (.next/server/app/api/signup/route.js:1:3871)
    at <unknown> (.next/server/app/api/signup/route.js:1:3913)
    at t.X (.next/server/webpack-runtime.js:1:1206)
    at <unknown> (.next/server/app/api/signup/route.js:1:3884)
    at Object.<anonymous> (.next/server/app/api/signup/route.js:1:3941)
> Build error occurred
[Error: Failed to collect page data for /api/signup] { type: 'Error' }
Error: Command "npm run build" exited with 1
Exiting build container


Vercel Environment Variable settings:
Answered by Burmese
Never mind. SIlly mistake of mine, some how I set 2 projects in Vercel pointing the same github project
View full answer

2 Replies

BurmeseOP
I have ran a re-deployment without cache and its still gives an error
BurmeseOP
Never mind. SIlly mistake of mine, some how I set 2 projects in Vercel pointing the same github project
Answer