Getting “404 not found” on doing a GET on local file in Azure web app

冷暖自知 提交于 2019-12-11 17:55:23

问题


I have deployed a simple node based web app in Azure. Following is the structure of my code:

In my js code, when I do an xhr.get call to my json file (as shown below), it throws a GET https://<app-url>/locales/en-US.json 404 (Not Found).

    xhr.open("GET", "locales/en-us.json", true);
    ...
    xhr.send();

As seen below, the calls to my js file and css file are succeeding but the call to my locale file is failing. External calls are working fine too. Note: js and css files have been included as part script tag and link tags respectively in my index.html file.

Could someone please help?


回答1:


It's a common issue of Azure Website which be lack of the mimetype setting for static json file, please refer to the blog. You just need to add the configurate below into your web.config file under wwwroot.

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

Then it works via your browser.



来源:https://stackoverflow.com/questions/53967169/getting-404-not-found-on-doing-a-get-on-local-file-in-azure-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!