Axios cors issue with Laravel Vue

32 Views Asked by At

When i use mounted in Vue3 everthing works. But using @click gives me an error. When i click the button fasts before the page loaded everything it returns json which should be expected.

Error message: Access to XMLHttpRequest at 'http://localhost:8000/auth/facebook/redirect' from origin 'http://localhost:5173' has been blocked by CORS policy: Request header field x-socket-id is not allowed by Access-Control-Allow-Headers in preflight response.

socialiteLogin(provider) {
    axios({
         method: "GET",
         headers: {
              'Content-Type': 'text/plain'
         },
         withCredentials: false,
         url: `/auth/${provider}/redirect`,
   })
     .then((res) => {
          console.log(res.data);
     })
     .catch((err) => {
          console.log(err.response);
     });
},
0

There are 0 best solutions below