javascript - Avoiding CORS restrictions on the Fetch API in Chrome -


i using fetch api in react+redux app this:

fetch("http://news.at.zhihu.com/api/4/news/before/20160127"). 

the app running in chrome , set --disable-web-security argument when open chrome. however, still cors issue:

fetch api cannot load http://news.at.zhihu.com/api/4/news/before/20160127. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8080' therefore not allowed access.

if use xmlhttprequest, works well. looks --disable-web-security can not work fetch api.

does know how use fetch api without worrying cors issue? can not modify response header such 'access-control-allow-origin' since services not in charge.

fetch('//news.at.zhihu.com/api/4/news/before/20160127', {   mode: 'no-cors' }).then(function(response) {   console.log(response) }).catch(function(err) {   console.log(err) }); 

have try.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -