socieboy
3 years ago
260
39
Vue

CORS and VueJS.

Posted 3 years ago by socieboy

Hi, I'm using VueJS to do a get request to another domain but I'm getting the error of CORS.

XMLHttpRequest cannot load http://xxx.xxx.xxx.xxx:94/. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://myvirualdomain.dev' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.

I set some parameters on the Vue global headers but I can't make it works yet. Some help please.

Vue.http.options.xhr = {withCredentials: true};
Vue.http.headers.common['Authorization'] = 'Basic ' + btoa("username:password");

Please sign in or create an account to participate in this conversation.