framework7 icon indicating copy to clipboard operation
framework7 copied to clipboard

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)

Open ducpm0301 opened this issue 7 years ago • 3 comments

I have code : app.request.setup({ crossDomain: 'true', headers: { 'Access-Control-Allow-Origin': '', 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept' }, beforeSend: function(xhr){ console.log("in before send !!!"); xhr.setRequestHeader('Access-Control-Allow-Origin', ''); xhr.setRequestHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); }, }); app.request.json('https://tiengnhateasy.com/test.json', function (data) { // app.request.json('http://localhost/html/tiengnhateasy_f7/www/test.json', function (data) { console.log("pageInit 00000000"); resolve( // How and what to load: template { componentUrl: './pages/catalog.html', }, { context: { myData: data, }, } ); }); } But err : Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (Reason: CORS header ‘Access-Control-Allow-Origin’ missing) Any idea how to fix it. Thanks so much!!!!!

ducpm0301 avatar May 03 '19 04:05 ducpm0301

You need to use the forum for issues like this: https://forum.framework7.io . also, CORS headers need to be set on top of your server/API scripts. Google on how to do it in PHP or use the cors package in Node JS. I have faced the same issue in the passed but setting these headers in the origin was so helpful.

Maxondria avatar May 03 '19 04:05 Maxondria

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 01 '19 05:08 stale[bot]

This issue has been automatically closed due to inactivity. If this issue is still actual, please, create the new one.

stale[bot] avatar Aug 15 '19 05:08 stale[bot]