得到"404未找到".在Azure Web应用程序中对本地文件执行GET操作 [英] Getting "404 not found" on doing a GET on local file in Azure web app
问题描述
我已经在Azure中部署了一个基于节点的简单Web应用程序.以下是我的代码的结构:
I have deployed a simple node based web app in Azure. Following is the structure of my code:
在我的js代码中,当我对json文件进行xhr.get
调用时(如下所示),它会抛出GET https://<app-url>/locales/en-US.json 404 (Not Found)
.
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();
如下所示,对我的js文件和css文件的调用成功,但是对我的语言环境文件的调用失败.外部呼叫也可以正常工作. 注意:js和css文件分别作为script
标签和link
标签的一部分包含在我的index.html
文件中.
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.
有人可以帮忙吗?
推荐答案
这是Azure网站的常见问题,缺少静态json文件的mimetype
设置,请参考
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.
这篇关于得到"404未找到".在Azure Web应用程序中对本地文件执行GET操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!