question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to append custom headers to axios request?

See original GitHub issue

I want to add a custom header x-dsi-restful to a get request. But I’m unable to append it through axios. Here is what I did getAppSettings().localRetailVehicleComparablesUrl }/k6MRDHbipIsp4BiKcNm66w/local_retail/comparables`, { method: ‘get’, withCredentials: true, headers: { ‘Content-Type’: ‘application/json; charset=utf-8’, ‘x-dsi-restful’: 1 }

Even though I added it to Header set Access-Control-Allow-Headers “x-dsi-restful, Authorization” I’m unable to append it to the request.

Only if I hardcode the value in apache conf the its working. Like RequestHeader append x-dsi-restful “1”

Is there a way to append it from axios?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

28reactions
ludbekcommented, Mar 19, 2019

Did you guys mean axios.get('url', {headers: {"x-dsi-restful":1}})?

26reactions
anthonygauthiercommented, Aug 20, 2018

Hi @ksairamya,

axios.get('url', {headers: "x-dsi-restful":1})

is not working?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Axios to set request headers - LogRocket Blog
Axios methods such as post() and get() enable us to attach headers to requests by supplying a headers' object as the second parameter...
Read more >
How to set header and options in axios? - Stack Overflow
There are several ways to do this: For a single request: let config = { headers: { header1: value, } } let data...
Read more >
How To Set Request Headers Using Axios? - RapidAPI
If you want to add headers only to specific request types like GET , you can use the defaults.headers.get property. This snippet will...
Read more >
How to Send Headers With an Axios POST Request
To send an Axios POST request with headers, you need to use the headers option. With axios.post() , the first parameter is the...
Read more >
Axios Cheat Sheet - Kapeli - Dash for macOS
Make a request for a user with a given ID axios.get('/user? ... `headers` are custom headers to be sent headers: {'X-Requested-With': 'XMLHttpRequest'}, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found