web.config for node.js angular RRS feed

  • Question

  • Hi,

    I have spent several hours trying to deploy a node.js web app (with angular and mongodb).

    This is a very simple "mean" app and i always got an error saying that url home/api/xxx is not found (404 error).

    Only the static web  pages are working.

    Can someone give me an exemple of a working web.config (I have tried many example of web config from the forum or the doc), because I can't find a detailed documentation about web config (I don't even know if iisnode is mandatory for node.js web app on azure.

    Thursday, July 19, 2018 5:37 PM

All replies

  • Share us the site name here or indirectly.   We can help investigate.


    Thursday, July 19, 2018 5:59 PM
  • The site url is :


    Friday, July 20, 2018 2:25 PM
  • If you run your application locally, does it work?   Try going to Kudu process explorere and see if the node application is running?    Do you have server.js file?


    Friday, July 20, 2018 6:32 PM
  • Just checking in if you have had a chance to see the previous response provided by Suwat Ch. We need previously asked information to investigate this issue further.
    Sunday, July 22, 2018 6:20 AM
  • Yes the application work locally.

    Yes I have a server.js file

    Sunday, July 22, 2018 6:05 PM
  • If you're deploying your Node app using zipdeploy but the zip doesn't contain the node_modules directory, you'll need to run `npm install` from KUDU to install the packages. Can you do a file diff on your local vs. prod environment to see if everything is there as expected?

    Tuesday, July 24, 2018 8:05 PM
  • Yes, like with any NodeJS app, pls make sure the dependencies in node_modules directory are installed as per suggestions made in previous replies. Did you establish database connection to mongodb successfully? Also, it looks your app is throwing reference error "$httpProvider is not defined" in DevTools console, have you checked to see if that might be the culprit?
    Tuesday, July 24, 2018 11:31 PM
  • Yes I have run 'npm install" from KUDU.

    All the packages are thus installed in the node_modules directory

    Wednesday, July 25, 2018 12:51 PM
  • Yes database connection to mongodb is successfull (if I change the mongodb connection string, just to test, I receive an error : database connection not established)
    Wednesday, July 25, 2018 12:53 PM
  • I have checked in the source code : yes i have a $http defined as parameter of angularjs controller.

    Note : The errors that appears in the DevTools console (visible in the browser's debugger), are not always the same : It depends of the web.config file that I have deployed (I have "experimented" dozens of web.config, but none are working as expected, as explained at the beginning of this thead).

    Wednesday, July 25, 2018 1:05 PM
  • For fixing the 404, try to add a web.config on the root with the below content and see if it helps:

    <?xml version="1.0" encoding="UTF-8"?>
             <rule name="AngularJS" stopProcessing="true">
               <match url=".*" />
               <conditions logicalGrouping="MatchAll">
                 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
               <action type="Rewrite" url="index.html" />

    For more details, you may refer to this article: https://techbrij.com/azure-app-services-github-deploying-mean.

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet. 

    Thursday, July 26, 2018 10:52 AM
  • I have put your web.config file (after have completely deleted mine), but it does not work better.

    I also have this error ( The resource you are looking for has been removed, had its name changed, or is temporarily unavailable ) on the url : home/api/hello

    Thursday, July 26, 2018 9:25 PM
  • This could be a static page issue. If you are using index.html as static, move it to /public and use express.static:

    app.use(express.static(__dirname + '/public'));

    For more information, you may refer to this SO thread.

    Reference: https://social.msdn.microsoft.com/Forums/azure/en-US/f85ef92d-10cd-4ce7-a009-22dbff1753ca/page-refresh-returns-quotthe-resource-you-are-looking-for-has-been-removed-had-its-name-changed?forum=windowsazurewebsitespreview.

    Sunday, July 29, 2018 10:54 AM
  • Hi clarence33

    I'd like to work together with you on this issue. Could you send us an email to azcommunity@microsoft.com with following details:
    - Subscription ID
    - URL to this thread

    Monday, July 30, 2018 7:03 PM
  • This is already like that : index.html in public directory and server.js contains :

    app.use(express.static(__dirname + '/public'));

    Tuesday, July 31, 2018 7:41 PM
  • @clarence33

    Could you send an email to azcommunity@microsoft.com as suggested by Mike? We will look into it further.
    Wednesday, August 1, 2018 8:18 AM
  • Could someone give a working example of a simple mean.js app and its deployment on azure ?

    Because after investigation, Mike told me that it was not an issue of web.config file.

    This is a show stopper for the app of my future startup !!

    Monday, September 10, 2018 8:42 AM
  • You may refer to this document for MEAN.js sample for Azure App Service and see if it helps.


    If this answer was helpful, click “Mark as Answer” or Up-Vote. To provide additional feedback on your forum experience, click here

    • Proposed as answer by Swikruti Bose Sunday, September 16, 2018 8:33 AM
    Sunday, September 16, 2018 8:33 AM
  • Checking in to see if the above response helped answer your question. Let us know if there are still any additional issues we can help with.

    Wednesday, September 19, 2018 6:33 AM
  • Hi,

       I had already read the document cited, but as the software architecture is not exactly the same, it had not help me (even if i think that i had followed the principle of the solution that is described in the document).

    Monday, September 24, 2018 3:35 PM