Hello I want create a Login Page, but get an error:
Access to fetch at ‘/login’ from origin has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
The Backend is a Laravel-PHP JSON REST API.
I can connect to the backend via terminal:
curl -d ‘{“name”:“c1312asd”, “email":"email2@email.de”,“password”:“12345asdfghj”}’ -H “Content-Type: application/json” http://localhost:8000/login
Get Back the Token.
{“token”:“eyJ0eXAiOi”}%
is there an error ?
const BACKEND_URL = “domain”;
let response = await fetch( BACKEND_URL, {
mode: 'cors',
method: 'POST',
header: {
'Accept': "application/json",
'Content-Type': 'application/json'
},
body: JSON.stringify({
name, password
})
});