[Vuejs]-Can't send GET request from Vue.js to CodeIgniter 3 backend

0👍

For starters, eliminate these two lines:

header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token');

You may want to add them back in once you get it working, but assuming there are no other influences (such as headers added by the web server itself), these are the most likely cause of the problem.

If that doesn’t solve your problem, then you’ll need to check your developer console to see all of the headers your request is sending and all of the headers your response is returning. Update your question with that information if you’re still having trouble.

0👍

try to set your XMLHttpRequest content type header to "application/x-www-form-urlencoded".
if you using axios then this is to config the header:

axios.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";

Leave a comment