我想将使用angular-cli创建的angular5应用程序部署到azure webapp服务。我做了什么:
新的testapp
构建--prod - aot
cd dist
//测试用例的脏部分:
去初始化
git add *
git commit -m'initial commit'
git remote添加azure https://[email protected]:443/xxx.git
git push azure master
输出:
顺利完成。 remote:运行部署后命令...远程:部署成功。 remote:App容器将在10秒内重新启动。
一切似乎都很好。如果我在部署完成后转到URL,我很遗憾地收到:
不能获取/
有错误:
内容安全策略:页面的设置阻止了自身加载资源(“default-src http://xxx.azurewebsites.net”)。来源:;!function(){var t = 0,e = function(t,e){ret .... xxx.azurewebsites.net:1
到目前为止,我见过的每一个教程或示例都没有对CSP或其他方面的任何打扰。有帮助吗?
尝试检查CSP标头如下,
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Content-Security-Policy" value="
default-src 'self';
style-src 'self' 'unsafe-inline';
script-src 'self' https://*.vo.msecnd.net;
connect-src wss: https:;" />
</customHeaders>
</httpProtocol>
</system.webServer>
您可以参考此文档,它将为您提供有关CSP的一些信息:https://www.henrihietala.fi/how-to-secure-your-asp-net-azure-web-app/。
另外,你可以参考这个MSDN线程:https://social.msdn.microsoft.com/Forums/vstudio/en-US/18425bf2-49d2-4ad6-824d-b84205ab0eea/adding-content-security-policy-xxss-protection-to-my-web-app?forum=windowsazurewebsitespreview,可能会有所帮助。