Env variable is set but production keep usinng the local env value
Unanswered
Nile Crocodile posted this in #help-forum
Nile CrocodileOP
I have the local .env.local setup
and this is how I use it in componen (a client component)
in production i keep seeing the app make this request "localhost:3000"? How is this possible? .env.local is not included in the repository how do it even know "localhost:3000"? am I using process.env.APPLICATION_BASE_URL wrong?
NEXT_PUBLIC_APPLICATION_BASE_URL=http://localhost:3000
and this is how I use it in componen (a client component)
useEffect(() => {
console.log("Fetching companies...");
console.log("process.env.APPLICATION_BASE_URL", process.env.NEXT_PUBLIC_APPLICATION_BASE_URL);
fetch(`${process.env.NEXT_PUBLIC_APPLICATION_BASE_URL}/api/deals`)
.then(response => response.json())
.then(data => {
if (Array.isArray(data)) {
setCompanies(data);
} else {
console.error("Fetched data is not an array:", data);
}
})
.catch(error => console.error("Error fetching companies:", error));
}, []);
in production i keep seeing the app make this request "localhost:3000"? How is this possible? .env.local is not included in the repository how do it even know "localhost:3000"? am I using process.env.APPLICATION_BASE_URL wrong?
5 Replies
Nile CrocodileOP
no
it got ignored
Nile CrocodileOP
I successfully make it to read the vercel env
What I did
1. Remove the var in the Enviroments Tab setting
2. Add the same var to Eviroment Variables
What I did
1. Remove the var in the Enviroments Tab setting
2. Add the same var to Eviroment Variables