Issue with Environment Variables in Deployed Next.js 13.5.6 App on Azure
Unanswered
West African Lion posted this in #help-forum
West African LionOP
Issue with Environment Variables in Deployed Next.js 13.5.6 App on Azure
I'm having trouble accessing an environment variable in my deployed Next.js 13.5.6 application on Azure. I have a function in utils/api/fileupload.ts that needs to access my backend URL stored as an environment variable. This variable works locally but is coming up as undefined in the deployed app.
I've tried both NEXT_PUBLIC_BACKEND and process.env.backend, but neither seems to work in the Azure environment.
Any advice on how to resolve this issue would be greatly appreciated!
I'm having trouble accessing an environment variable in my deployed Next.js 13.5.6 application on Azure. I have a function in utils/api/fileupload.ts that needs to access my backend URL stored as an environment variable. This variable works locally but is coming up as undefined in the deployed app.
I've tried both NEXT_PUBLIC_BACKEND and process.env.backend, but neither seems to work in the Azure environment.
Any advice on how to resolve this issue would be greatly appreciated!
1 Reply
West African LionOP
Code in utils/api/fileupload.ts that is causing me problems
const backendPy = process.env.PY_BACKEND_IP || "http://localhost:8000";
console.log("backendPy: ", backendPy);
try {
// Send a POST request to upload the file
const response = await axios.post(
`${backendPy}/api/documents?session_id=${session_id}&user_id=${user_id}&database_code=${db}`,
formData,
{
headers: {
'Content-Type': 'multipart/form-data',
}
}, // Attach the FormData with the file to the request
);`