I use axios for calling API (in front-end). I use the method \"GET\" :
import axios from \'axios\';
import querystring from \'querystring\';
var url = \"m
So the way to solve this npm install qs
.
Then:
import qs from 'qs'
function send(params) {
return axios.post('/api/create/', qs.stringify(params))
}
In the response header I had Allow:"GET, HEAD, POST, PUT, DELETE"
.
So OPTIONS
method is not available and need to configure it on in the server (Apache).
I do the change on apache (/etc/apache2/sites-available/000-default.conf) :
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "*"
Header set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
In Request headers I have :
file:// URLs produce a null Origin which can't be authorized via echo-back. Don't trying to perform a CORS request from a file:// URL (see this post for more details)