我目前正在嘗試使用 Google App Engine/Go + Polymer.dart 網站http://xclamm.appspot.com/。問題是當我使用Dartium (31.0.1612.0 Developer Build 219647)訪問http://xclamm.appspot.com/時出現以下錯誤。XMLHttpRequest cannot load https://talkgadget.google.com/talkgadget/channel.js. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xclamm.appspot.com' is therefore not allowed access. 我做了一些研究,發現問題與我如何引用有關/_ah/channel/jsapi,但我找不到如何解決它。我嘗試了以下方法來引用 channel.js,但仍然出現相同的錯誤。<!-- Following doesn't work --><script type="text/javascript" src="/_ah/channel/jsapi"></script><!-- Following doesn't work either --><script type="text/javascript" src="https://talkgadget.google.com/talkgadget/channel.js"></script>如果我在 dev_appserver.py 上運行網站,它似乎工作正常。我錯過了什么嗎?源代碼可在https://github.com/rillomas/xclamm-gae 獲得,我使用的是 Google App Engine SDK 1.8.4 for Go (x64 Windows)。
1 回答

莫回無
TA貢獻1865條經驗 獲得超7個贊
我將<script type="text/javascript" src="/_ah/channel/jsapi"></script>
標簽從main-stage.html
(內部 Web 組件的index.html
html )移動到(網站的根 html),然后 CORS 錯誤消失了。
該<script>
標簽最初被放置在一個<polymer-element>
標簽內,并且(可能)被 Polymer.dart 轉換為 XMLHttpRequest,從而導致錯誤。
- 1 回答
- 0 關注
- 236 瀏覽
添加回答
舉報
0/150
提交
取消