[英]No route registered for static file in Azure App Service
我有一个运行 ReactJS 应用程序的 Azure 应用服务。 在发布管道中,我提取了一个包含赛普拉斯测试结果的 zip 文件。
当我导航到 Kudu 控制台时,我可以在PS D:\\home\\site\\wwwroot\\e2e\\mochawesome-report>
文件夹中找到正确的文件夹和文件。 但是当我导航到视频时:
https://exampleUrl/e2e/mochawesome-report/video/onboarding.spec.js.mp4
您要查找的资源已被删除、更名或暂时不可用。
但是当我导航到: https://exampleUrl.azurewebsites.net/e2e/mochawesome-report/screenshot/customer-card.spec.js/Customer card action tab -- can click on the account tab (failed).png
: https://exampleUrl.azurewebsites.net/e2e/mochawesome-report/screenshot/customer-card.spec.js/Customer card action tab -- can click on the account tab (failed).png
我可以查看图像。
查看静态文件是否需要一些配置?
##编辑##
添加了我的 web.config:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我很确定我在网上的某个地方找到了这个。
我注意到的另一件事。 我现在可以打开 .html 和 .css、.js 和 .png 文件,但不能打开 .json、.woff、.woff2 和 mp4。
您需要为您的 Web 应用程序定义文件扩展名。
将这些行添加到您的web.config
,在您的</rewrite>
下方,然后重新启动您的 Web 应用程序:
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
添加其他扩展(如json
):
<mimeMap fileExtension=".json" mimeType="text/plain" /
结果将是:
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".json" mimeType="text/plain" /
</staticContent>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.