0

I am doing development in reactjs on my localhost. I have an api written in nodejs deployed at https://bianca-service-dev0.cfapps.io

Using react i am calling an auth endpoint in the api to login my user. The auth endpoint returns a token to me in response body and a cookie name CSRF-TOKEN. When i try to view document.cookie i only see the cookies set by my localhost and dont see cookies set by the api.

Can I access cookies set by a different domain?

1
  • 2
    No, because you can only access cookies from your domain Commented May 29, 2018 at 19:03

1 Answer 1

1

Not directly.

JavaScript running in the browser can only read cookies associated with the page that the JS is running on.

Requests to other origins (if sent withCredentials) will include the cookies transparently though so you can still use them to access content on the origin that set them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.