Azam Maqsood
Azam Maqsood

Reputation: 69

Node.js Route not working on Microsoft Azure

Hello I build a very basic Node.js app (without any framework), I set up a route. index.html and login.html

on my local machine (windows 10) its working fine. both files index.html and login.html show up in browser when I call them from url. like

localhost/myapp => loads index.html localhost/myapp/login => loads login.html

Now I deploy it on Microsoft Azure, and now only index file is loading, when i try to load myapp.azurewebsites.net/login it said this : The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

I have a web.config file with these settings

<?xml version="1.0"?>
<configuration>
<system.webServer>
     <staticContent>
     <mimeMap fileExtension=".html" mimeType="text/html" />
  </staticContent>
</system.webServer>
</configuration>

please guide me how to enable routing in node.js on azure. without any framework. there is no help on official docs.

thanks

Upvotes: 1

Views: 1177

Answers (3)

tim
tim

Reputation: 378

You could use the Azure Node JS Starter Site or Node JS Empty Web App.

enter image description here

In those projects you will find the right web.config file that you need to run Node applications in Azure.

Upvotes: 0

Azam Maqsood
Azam Maqsood

Reputation: 69

well after a lot of search I figure out the solution. you need to set web.config file from their demo project and upload into your own azure project. https://github.com/Azure-Samples/nodejs-docs-hello-world/archive/master.zip

Upvotes: 1

Zahid Faroq
Zahid Faroq

Reputation: 355

Try to add below code in web.config file and see if it works.

<configuration>
<system.webServer>
    <rewrite>
      <rules>
        <rule name="Main Rule" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="/" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

For more details on this error follow this link.

Upvotes: 0

Related Questions