[SOLVED] Getting CORS error-No 'Access-Control-Allow-Origin' header is present |
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
Cross-Origin Resource Sharing (CORS)
I was get errors on fonts and had to add this to the .htaccess file. Code: # Add Font Types What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(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({ |
Welcome Guest, Not a member yet? Register Sign In |