Description
I am new to React and decide to use create-react-app for my next project. Now I have an api server at myapi.domain.com and it is authorized by using cookie. In my react project, I use fetch to make request, for example, at myapi.domain.com/v1/getData. When I compare this request with the request I type directly to browser address, I can see a difference.
Expected behavior
The connect.sid value in Cookie field in 2 requests headers are the same.
Actual behavior
The connect.sid value in Cookie field in 2 requests headers are different, so my api server cannot authorize the request.
I assume that when using fetch, the request is not called from client-side, so it cannot get the cookie stored in browser.
So in this case, how can I call a request from client-side (to use cookie stored in browser)?
Sorry for my bad English and explanation.
Description
I am new to React and decide to use
create-react-appfor my next project. Now I have an api server atmyapi.domain.comand it is authorized by using cookie. In my react project, I usefetchto make request, for example, atmyapi.domain.com/v1/getData. When I compare this request with the request I type directly to browser address, I can see a difference.Expected behavior
The
connect.sidvalue inCookiefield in 2 requests headers are the same.Actual behavior
The
connect.sidvalue inCookiefield in 2 requests headers are different, so my api server cannot authorize the request.I assume that when using
fetch, the request is not called from client-side, so it cannot get the cookie stored in browser.So in this case, how can I call a request from client-side (to use cookie stored in browser)?
Sorry for my bad English and explanation.