Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Request header field apptoken is not allowed by Access-Control-Allow-Headers in preflight response

I'm using axios.get request and i'm trying to add the request custom header, but i get an error everytime!

getAll() {
    const token = this.state.token;
    axios.get('http://localhost:3000/tenant',{
        headers:{
            'apptoken': this.props.token
        }
    })
        .then((res) => {
            console.log("res", res);*emphasized text*
        }).catch((err) => {alert("something is wrong") });
}

the error i get is: " Access to XMLHttpRequest at 'http://localhost:3000/tenant' from origin 'http://localhost:3001' has been blocked by CORS policy: Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response."


now i saw other solutions here and i tried to write: 'Access-Control-Allow-Headers:*' but it didn't work for me.

help :(

Comments