Angular5部署到Azure webapp:内容安全策略

时间:2017-12-16 18:25:26

标签: angular azure azure-web-sites angular-cli azure-web-app-service

我想将使用angular-cli创建的angular5应用程序部署到azure webapp服务。我做了什么:

ng new testapp

ng build --prod --aot

cd dist

//测试用例的脏部分:

git init

git add *

git commit -m'初始提交'

git remote add azure https://user@xxx.scm.azurewebsites.net:443/xxx.git

git push azure master

输出:

  

成功完成。 remote:运行部署后命令...   远程:部署成功。 remote:应用程序容器将开始   在10秒内重启。

所以一切似乎都很好。如果我在部署完成后转到URL,我很遗憾地收到:

无法获取/

错误:

内容安全策略:页面的设置阻止了自身加载资源(“default-src http://xxx.azurewebsites.net”)。来源:;!function(){var t = 0,e = function(t,e){ret .... xxx.azurewebsites.net:1

到目前为止,我所看到的每一个教程或示例都从未打扰过CSP或其他任何方面。有什么帮助吗?

1 个答案:

答案 0 :(得分:1)

尝试检查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,可能会有所帮助。

相关问题