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.

Refused to set unsafe header 'Cookie'

See original GitHub issue

const request = axios.create({ baseURL: ‘http://www.someurl.com/’, headers: { ‘Cookie’: ‘some_string_value’ } });

throws an error Refused to set unsafe header 'Cookie'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
joembayacommented, Nov 29, 2018

@samayo Your axios header should look like this:

In your Javascript code: const axiosConfig = { headers: { ‘content-Type’: ‘application/json’, “Accept”: “/”, “Cache-Control”: “no-cache”, “Cookie”: document.cookie }, credentials: “same-origin” }; axios.defaults.withCredentials = true; axios.get(‘/url’, axiosConfig) .then((res) => { // Some result here }) .catch((err) => {
console.log(‘😦’); });

I hope it helps…

3reactions
samayocommented, Dec 1, 2018

Thanks @joembaya, I have looking for the answer since August 2017 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refused to set unsafe header "Cookie" error in browser yet ...
You get that error from Chrome because, per the XHR specification, the setRequestHeader method should not set headers with a forbidden ...
Read more >
Refused to set unsafe header "Cookie" - Syncfusion
Refused to set unsafe header "Cookie". I am attaching the ASP.NET Identity cookie and passing it to the controller as the domain name...
Read more >
jQuery : Cookie Header in PhoneGap: Refused to set unsafe ...
jQuery : Cookie Header in PhoneGap: Refused to set unsafe header " Cookie " [ Beautify Your Computer ...
Read more >
axios set cookie in header | The AI Search Engine You Control
As it seems, it is not possible to read the Set-Cookie header via Axios, as @jub0bs pointed out. ... "refused to set unsafe...
Read more >
Use of Cookie header for authentication means that remote ...
You can not set the 'Cookie' header when making a XMLHttpRequest. Attempting to do so results in a 'Refused to set unsafe header...
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