Axios vs jQuery post CORS issue
Problem
When doing a CORS post request, jQuery succeeds but Axios gets a CORS error in the console. This gets a CORS error [code block] But this works [code block] Am I missing something with Axios? My server is already configured for CORS requests.
Error Output
error in the console.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Axios vs jQuery post CORS issue
I had this problem as well, but I got it working now as I simply had Access-Control-Allow-Origin set up wrong on the server side. I suspect that the rest of you have this as well because jquery POST sends the requests as application/x-www-form-urlencoded as default, and thus doesn`t get preflighted. While axios correctly sends it as application/json and will be preflighted.
Trust Score
3 verifications
- 1
I had this problem as well, but I got it working now as I simply had Access-Cont
I had this problem as well, but I got it working now as I simply had Access-Control-Allow-Origin set up wrong on the server side. I suspect that the rest of you have this as well because jquery POST sends the requests as application/x-www-form-urlencoded as default, and thus doesn`t get preflighted. While axios correctly sends it as application/json and will be preflighted.
Validation
Resolved in axios/axios GitHub issue #113. Community reactions: 2 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep