簡體   English   中英

Chrome / IE,AngularJS和Access-Control-Allow-Origin

[英]Chrome / IE, AngularJS, and Access-Control-Allow-Origin

我正在AngularJS中構建一個可以通過CD分發的Web應用程序,但我分別使用Chrome和IE的原始策略打了一個磚牆:

XMLHttpRequest cannot load file:///xxx. Origin null is not allowed by Access-Control-Allow-Origin. 

有什么方法可以通過代碼或其他方式繞過這個嗎?

我使用的解決方案是通過<script type="text/ng-template">指令在index.html文件中內聯定義所有模板,如下所示:

<script type="text/ng-template" id="/template.html">
     <h1>I'm the content</h1>
</script>
<ng-include src="/template.html"></ng-include>

是的,你可以
delete $http.defaults.headers.common['X-Requested-With'];

在請求之前

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM