backend express
app.all("*", function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Headers", "Content-Type");
next();
});
Front-end axios
import axios from "axios"
axios.defaults.baseURL = "http://localhost:5001"
var formdata = new FormData();
formdata.append("file", f);
axios({
url: "/",
method: "post",
data: formdata,
headers: {"Content-Type": "multipart/form-data", "Access-Control-Allow-Origin": "*"}})
.then(function (res) {
console.log(res)
})
.catch(function (err) {
console.log(err)
})
the app.all response header code has been added to the express code. Why is it still a problem for
to send a request at the front end?