I’ve tried to fetch data from Wordpress API in vue.js App.
when using DigitalOcean with Apache.
I’ve set Header set Access-Control-Allow-Origin “*“ in vhost.
But now I’ve got an error like this:
Access to XMLHttpRequest at xxx from origin ‘http://localhost:3000' has been blocked by CORS policy: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘http://localhost:3000, *‘, but only one is allowed.
when using axios for requests.
Do you have any ideas what’s going on?
Is it server side issue or should I set something in axios config?
Thanks.
Solution :
This is a server-side issue. You need to enable CORS in the apache config, by either:
Setting Header set Access-Control-Allow-Origin “*“ - meaning that all origins are allowed to make requests to this server
Setting Header set Access-Control-Allow-Origin “http://localhost:3000"
This tells the server to accept requests from this origin(s), to further explain.