Help! My Next.js App is Still Pointing to localhost in Production

August 22, 2025 5 answers
Asked by DevNinja42
I'm a full-stack developer and I've got a Next.js application that's been deployed on Azure App Service by my DevOps team using a CI/CD pipeline. Unfortunately, I mistakenly sent them an `.env` file that contains `BASE_URL=http://localhost:3000`. As a result, all requests from the app in production are still pointing to localhost. I attempted to fix this by updating the environment file with the correct production URL and pushing it to the pipeline, but nothing changed. The app continues to send requests to localhost:3000 despite my changes. I've also tried modifying the environment variables through GitHub Actions, but I'm still facing the same issue. I'm not sure if it's an issue with the application code or the production environment itself. Any insights or suggestions would be greatly appreciated!

Answers

CodeMasterX
What steps have you already taken to fix this?

DevNinja42: Iโ€™ve tried pushing the updated `.env` to the codebase, made tweaks through GitHub Actions, and scoured the entire code for any hardcoded localhost entries to ensure there arenโ€™t any. But it looks like something is still overriding the updated URL, reverting it back to localhost:3000.

Reply to this answer
CodeWizard88
Oh man, that's a classic headache! First off, you really shouldn't send `.env` files to your DevOps team. They should ideally be managing environment variables in the deployment settings themselves. That said, since youโ€™re not seeing any changes after the latest push, it's possible something else could be going on. Maybe thereโ€™s a CDN caching those requests, or your deployment didnโ€™t register the changes. Also, double-check if your browser is caching older versions of the app. My suggestion is to have a chat with your DevOps team to see what their deployment process looks like and stick to that for future changes!
Reply to this answer
RandomDev99
How did you even manage to get hired!?

DevNinja42: Bro, I swear I'm not a DevOps expert! Things like these happen.

Reply to this answer
AzureSeeker22
Take a look at the Azure App Service dashboard. It has built-in environment variable settings that you can configure directly. You should set your `BASE_URL` there instead of relying on the `.env` file. Once updated, redeploy your app and see if that resolves the issue.
Reply to this answer
DebuggingGuru77
You might need to do a full rebuild or redeploy along with clearing any cache that's stored in your runners. Sometimes, if the caching layers arenโ€™t cleared, it can lead to stale data showing up.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions