Replies: 2 comments
|
Yeah this is almost always one of two things when it's fine locally but breaks after deploying to Azure. If you're on Azure Static Web Apps, the routing in front of your app expects API stuff to live in a specific If it's a regular Azure App Service instead, the usual culprits are the Startup Command not being set (or pointing at the wrong file — should be something like Honestly the fastest way to figure out what's actually going on instead of guessing is to turn on Log stream in the portal (or Let me know which Azure service you're on (App Service, Static Web Apps, or Functions) and I can point you more specifically. |
|
I have been through this exact issue, so let me save you some time. The most important clue is the error message itself. "Cannot GET /api/users" is Express's own 404 response, which means your app is running on Azure and is receiving the request. It just cannot find a route for that path. So this is almost never a "server did not start" problem. It is either a route that does not match, or the request never reaches Express at all. First, confirm Express is the one answering: If the response contains "X-Powered-By: Express", your app handled the request and we move to the next step. If it does not, something in front of your app is eating the request, usually Azure Static Web Apps routing, an IIS web.config rewrite on Windows App Service, or a load balancer. If Express is answering, make it tell you what it actually receives. Add this at the very end of your route setup, after all routers: Then hit the endpoint and read the Azure log stream (App Service, your app, then Log stream). You will see the exact URL that arrived. The three causes I see most often:
A few more quick checks:
If you tell me which Azure service you used (App Service on Windows, App Service on Linux, Static Web Apps, or Container Apps) and the output of the curl above, I can point at the exact line. Once this clicks you will never struggle with it again. |
Uh oh!
There was an error while loading. Please reload this page.
Hey, I am new learning about devops and deployment, I ran into a problem when deploying my api in Azure,
Cannot GET /api/users, I tested my application in a local environment and everything works perfectly, however I don't know what is happening, i I already specified the port asprocess.env.PORTand established the connection strings in azure. I would really appreciate the help, if you want to know more about my project you can visit my ExpressApi repository its a simple ecommerce api, in the same way I would appreciate opinions on my code and ideas, I'm just learning about in expressAll reactions