![]() |
[SOLVED] Getting CORS error-No 'Access-Control-Allow-Origin' header is present - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [SOLVED] Getting CORS error-No 'Access-Control-Allow-Origin' header is present (/showthread.php?tid=71221) |
[SOLVED] Getting CORS error-No 'Access-Control-Allow-Origin' header is present - aslamdoctor - 07-20-2018 I have created an API server using codeigniter. I haven't used any kind of rest api libraries. Just created array of data and did json encoding on it. Now I am trying to fetch the data by making ajax request to this API server but getting this error No 'Access-Control-Allow-Origin' header is present on the requested resource This is because the request I am sending is from different server(or different URL). These both API server and Ajax client app are set up locally only. So is there any way I can bypass this access-control check for development purpose? as the final app is going to be uploaded to same URL and there I don't have to worry about this error. Thank You, Aslam RE: Getting CORS error-No 'Access-Control-Allow-Origin' header is present on the request - InsiteFX - 07-20-2018 Cross-Origin Resource Sharing (CORS) I was get errorsĀ on fonts and had to add this to the .htaccess file. Code: # Add Font Types RE: Getting CORS error-No 'Access-Control-Allow-Origin' header is present on the request - aslamdoctor - 07-20-2018 (07-20-2018, 08:40 AM)InsiteFX Wrote: Cross-Origin Resource Sharing (CORS) Fixed it. It was not the issue with access control but stupid js was showing error for it. It was actually happening because I was doing post request using axios and the data I was passing to the ajax request was a js object. It was needed to be stringified using the qs.stringify method. I did it and it got fixed. Btw, I am using vue js for this app. And here is my final code Code: this.$axios({ |