0👍
This issue arises because jQuery sends the request as application/x-www-form-urlencoded
by default and does not send preflight request whereas axios sends as application/json
and sends a preflight request i.e. OPTIONS before sending actual request.
One way it could work is by setting Content-type
header to 'Content-Type': 'application/x-www-form-urlencoded'
in axios.
You will have to change the settings on server side to get around this issue.
0👍
Add this in your web.config
file:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Using default ajax won’t send any OPTIONS request, but using axios does. This will enable accepting OPTIONS requests.
- [Vuejs]-Vue FullPage.js changing Options on method
- [Vuejs]-Localhost:3000 is not working properly in windows while creating a reactjs app with CRA
Source:stackexchange.com