DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Fabio
Fabio

Posted on

Deploy React app to Azure App Service as a SPA

Hello everyone,
I've some issue during deploiment of my React application to Azure App Service.
I've created the "build" by running npm run build, and then i've uploaded the content of build folder to "/site/wwwroot". At least step I've created the web.config file for manage the routing of React App.
But it seems not working the routing. Because when I try to reach others path I see this error: "Not Found The requested URL /implicit/callback was not found on this server."

Many thanks
Best regards
Fabio

Top comments (4)

Collapse
 
anthony profile image
Anthony Chu

Hey Fabio. Are you using Linux or Windows App Service?

Collapse
 
fabiofi profile image
Fabio

Hello Anthony, I'm using linux app service with PHP 7.3

Collapse
 
anthony profile image
Anthony Chu

Hi Fabio,

PHP is the right stack to use for this on Linux. However, it uses Apache instead of IIS, so a web.config file won't work.

Instead, create a .htaccess file in /home/site/wwwroot like this:

RewriteEngine On
RewriteRule "^[^\.]+$" "index.html"

It rewrites any path that doesn't contain a . to the index page, which should work for most single page apps deployed this way. If your app is different, you may have to tweak this somewhat.

Thread Thread
 
fabiofi profile image
Fabio

Many thanks Anthony,
I've changed to Windows instead of Linux and it works. Have a nice day.
Fabio

Stop sifting through your feed.

Find the content you want to see.

Change your feed algorithm by adjusting your experience level and give weights to the tags you follow.