1

I am using the fetch api with react-native on Android. In a following request I include the cookie in headers. However, when the cookie is received serverside it is in a different form to what I set.

For example.

fetch(someUrl, {
  method: 'GET',
  credentials: 'include',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Access-Control-Allow-Credentials' : 'true',
    'Cookie' : 'auth="eyJfdXNlciI6WzUwNzQ2NTk5ODg5OTYwOTYsMSwiQ0ZPekljV3pObnIwMFVjTzlOUGswYyIsXX0\075|1470686650|321"',

  },
})
.then((response) => response.text())

however, the headers I receive serverside show the cookie as:

'Cookie': 'auth=eyJfdXNlciI6WzUwNzQ2NTk5ODg5OTYwOTYsMSwiQ0ZPekljV3pObnIwMFVjTzlOUGswYyIsXX0\\075|1470686650|321'

The transmission subtly changes the cookie. For example there are no inverted commas " on either side of the value. Any ideas how I can transmit this cookie as is? I've attempted to escape the inverted commas using \" but it's still received serverside malformed.

Edit

If I send the exact same cookie in python, using the requests api it gets transmitted in tact. This indicates that it is not an illegal character issue.

If I send the exact same cookie using React Native in iOS it gets transmitted in tact. This indicates that it is not an illegal character issue.

If I send the exact same cookie using a web client it gets transmitted in tact. This indicates that it is not an illegal character issue.

RNu1234
  • 73
  • 8

0 Answers0