J
J
JordanBelford2021-01-25 06:28:50
Node.js
JordanBelford, 2021-01-25 06:28:50

What headers need to be sent in order for the put and delete methods to work?

Good afternoon! I wanted to write a simple MERN application, but the problem is that for the http - put, delete methods, you need to know cors. I can not understand what headers should be sent from the client and server side. The only thing I understood is that it is necessary to send headers from both the client and the server side.
Here is an example how I did it for get, post:

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pastukhov, 2021-01-25
@JordanBelford

Use cors or
Access -Control-Allow-Origin: * Access-Control-Allow-Methods: POST, PUT, DELETE, OPTIONS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question