I am working on a react app which receives httponly cookie from third party website.
I am able to see the cookie in Chrome developer console.
I am trying to send this cookie to backend of my app, built in expressjs, so that I can read the cookie. I am using fetch to send a GET request to the app while including the prop below:
Credentials: 'include'
In the express server, am allowing my front-end inside CORS and also
set credentials equal to true.
Issue:
In request header of my express server, I can't see the httponly cookie.
Can anyone guide me how can I send httponly and get it inside express server?
On client you must enable credentials as well. There is axios module to make requests with credentials. Example of usage:
import axios from 'axios'
const instance = axios.create({
withCredentials: true,
baseURL: API_SERVER
})
instance.get('todos')
In other way, you could provide cookie with XMLHttpRequest:
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://example.com/', true);
xhr.withCredentials = true;
xhr.send(null);
XMLHttpRequest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With