Express cross-domain problem

create an express project by yourself, connect to the remote mysql, write interface, use the browser address to access successfully and get the data.

A front-end project is built using vue family buckets, and axios processes requests across domains.

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

added the following code, but still had no effect:

res.header("Content-Type", "text/plain");
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

is there anything I need to set up for the axios request header?


Request header field timestamp is not allowed by Access-Control-Allow-Headers in preflight response.
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, timestamp ");

attach a link: https://www.cnblogs.com/king-.

Menu