Skip to content

Call API Request from Client-side to use cookie for Authorization #828

Closed
@dzuncoi

Description

@dzuncoi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions