Next.js Discord

Discord Forum

Problem with NEXT env variable

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
Hello, I got a problem,

as example i got in my local .env this - NEXT_PUBLIC_SERVER_URL=http://localhost:3000

but then i try to get my application to production with Docker and I put there as example again NEXT_PUBLIC_SERVER_URL=https://ecommerce.ssshhhhtt.cloud , which is right, it is the URL on which my server is running

if i try to call NEXT_PUBLIC_SERVER_URL to fetch data from example NEXT_PUBLIC_SERVER_URL /api/prudcts it is working perfect - getting https://ecommerce.ssshhhhtt.cloud/api/products

but the when i get to my context providers, as example here the AuthProvider which are 'use client' client component and i try to call the api for example NEXT_PUBLIC_SERVER_URL/api/me i get this url https://ecommerce.ssshhhhtt.cloud/undefined/api/me


where can this /undefined comes from, someone with idea?

1 Reply

Transvaal lionOP
basically every time i have a Provider used like AuthProvider, CartProvider, FilterProvider which are all client components i get this /undefined after my NEXT_PUBLIC_SERVER_URL and /api/whatever we need