當用Chrome 測試時, 若於本機建立localhost 並進行HTTP request 時, 會出現以下錯誤:
XMLHttpRequest cannot load http://rss.weather.gov.hk/rss/WeatherWarningSummaryv2_uc.xml. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:52616' is therefore not allowed access.
這是Chrome一個Known issue , 當在本機以localhost 叫用時便會發生.
要解決的話, 最快的方法就是停用security settings. 利用以下command 執行Chrome 便可.
chrome --user-data-dir="C:/Chrome dev session" --disable-web-security
執行後, 會有一行提示, 略過便可.
Leave a Reply