[Chrome] 解決Localhost 進行HTTP request 時之錯誤

當用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

執行後, 會有一行提示, 略過便可.

About C.H. Ling 260 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.