Can't set headers for DELETE method
See original GitHub issueI create an instance of axios:
const api = axios.create({ baseURL: process.env.BASE_URL, timeout: 1000, });
I am able to set the header for POST:
api.defaults.headers.post['X-CSRFToken'] = cookie.csrftoken;
However, if I try to set the header for DELETE:
api.defaults.headers.delete['X-CSRFToken'] = cookie.csrftoken;
I get the following error: Cannot set property ‘X-CSRFToken’ of undefined
Is this expected behavior?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
How to enable DELETE request? - Stack Overflow
I solved it without adding new packages, just added this line res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE");.
Read more >Access-Control-Allow-Headers - HTTP - MDN Web Docs
The Access-Control-Allow-Headers response header is used in response to a preflight request which includes the ...
Read more >Troubleshoot CORS errors from API Gateway - AWS
The following example procedure shows how to troubleshoot the No 'Access-Control-Allow-Origin' header present CORS error.
Read more >Cannot set headers after they are sent to the client in JS
The "Cannot set headers after they are sent to the client" error occurs when the server in an express.js application sends more than...
Read more >HTTP/1.1: Method Definitions
Although this set can be expanded, additional methods cannot be assumed to ... The Host request-header field (section 14.23) MUST accompany all HTTP/1.1 ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
in my case doing delete with axios in below method doesn’t send header.
but this way it’s working correctly
axios.delete({ url: ‘/system/ABC/delete/’ + selectedId, headers: {‘Authorization’: 'Bearer ’ + token}, withCredentials: true }).then(function (response) {…
i try to use csrf in delete , but i am getting this error in node.js
DELETE http://localhost:3131/system/ABC/delete/473TL095G3x-HpugwipBP0RAMmyer5cPDafrNg0 403 (Forbidden)