When attempting to make a request from ‘http://localhost:3000’ to ‘http://localhost:8000/home’ (redirected from ‘http://localhost:8000/login’), I encountered a CORS policy error. The error message states that the ‘Access-Control-Allow-Origin’ header is missing in the preflight response, blocking the request. How can I resolve this CORS policy issue in my Laravel application?
this is my cors.php file enter image description here
‘paths’ => [‘api/*’, ‘/login’, ‘sanctum/csrf-cookie’],
'allowed_methods' => ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
'allowed_origins' => ['http://localhost:3000'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
this is my react axios
import Axios from “axios”;
const axios = Axios.create({
baseURL: “http://localhost:8000”,
withCredentials: true,
xsrfCookieName: “XSRF-TOKEN”,
xsrfHeaderName:”X-XSRF-TOKEN”,
headers: {
‘X-Requested-With’: ‘XMLHttpRequest’
},
});
how to finding this solutions???
i will try to change the cors header & origin but i didn’t the solution
ABDUL MAJID is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.