How to fix cannot get root on azure app service

Shreepad Divekar 0 Reputation points
2024-10-31T04:42:32.66+00:00

I am deploying a multicontainer application, react js frontend, node js backend. The app works perfectly locally, but whenever deployed on azure, all i see is CANNOT GET / , i know its not a lot of info, but im willing to provide more

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,880 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RevelinoB 3,345 Reputation points
    2024-10-31T05:13:04.0733333+00:00

    Hi Shreepad,

    Many customers deploying multicontainer applications with a React frontend and Node.js backend report seeing the "CANNOT GET /" error on Azure, even if everything works smoothly in their local environment. This issue is commonly linked to a few key deployment settings. Here’s what to check:

    Server Configuration: Often, the server isn't set up to serve static files correctly. Ensure that your web server (like Nginx or Apache) is configured to point to the correct location for your React build files.

    Dockerfile Accuracy: Misconfigured Dockerfiles are another frequent cause. Verify that your frontend Dockerfile builds and copies files to the correct directory. Ensure that both your frontend and backend containers are networked and communicating properly.

    Port Mapping: Double-check that the frontend container’s port is correctly mapped and that your application is listening on the expected environment port on Azure.

    Azure App Service Configurations: When using a docker-compose.yml file, customers often overlook correct paths and networking. Confirm that your start scripts or CMD commands target the app’s correct entry points.

    React Router Fallback (if using client-side routing): If your React app uses client-side routing, a common fix is to add a fallback route in the server configuration to serve index.html on unknown routes, ensuring proper routing.

    If this sounds familiar, or if you have any specific error logs, I’d be happy to help with further troubleshooting!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.