Next.js Discord

Discord Forum

procss.env.CLIENT_ID returns undefined in callback/provider/route.ts

Unanswered
Tonkinese posted this in #help-forum
Open in Discord
TonkineseOP
Is this expected?

6 Replies

TonkineseOP
body: new URLSearchParams({
      client_id: "<CLIENT_ID>",
      client_secret: "<CLIENT_SECRET>",
})
works but
body: new URLSearchParams({
      client_id: process.env.CLIENT_ID,
      client_secret: process.env.CLIENT_SECRET,
})
doesn't
(in side api/auth/callback/discord/route.ts)
new URLSearchParams({})
also won't take the code: code input from
export async function GET(req: Request) {
  const urlParams = new URL(req.url).searchParams;

  const code = urlParams?.get("code");
lol what is going on
it's fine if i give it the hard-coded string value, but as soon as i try to pass it the code variable, it shows an error
type "null" is not assignable to type "string | undefined"