GithubHelp home page GithubHelp logo

Comments (15)

luckydrq avatar luckydrq commented on June 9, 2024 4

It's weird. In your case in koajs/koa#689, the requests are all belong to the same domain which is 9.xiaojukeji.com, i think {credentials: 'same-origin'} is not necessary. Did i miss something?

from isomorphic-fetch.

grillermo avatar grillermo commented on June 9, 2024 2

My call to fetch endeup like this
fetch(url, {credentials: 'same-origin'})
And it worked for me!

from isomorphic-fetch.

qubaomingg avatar qubaomingg commented on June 9, 2024 1

@luckydrq yeah. about receiving not sending, it's also the scene I came cross.
I found if there is no {credentials: 'same-origin'} ,isomorphic-fetch would't send browser cookie in get request, and then browser would't save cookies even if the response carried cookies.

then I found jquery ajax send cookies either receiving or sending, and when I add the credentials it works well. so I guess that's the key.

from isomorphic-fetch.

qubaomingg avatar qubaomingg commented on June 9, 2024

@darrenchiusw I came across the same scene.
I debug for a long time and it turn out it's the bug of isomorphic-fetch, which works well when I change to jquery.

from isomorphic-fetch.

qubaomingg avatar qubaomingg commented on June 9, 2024

isomorphic-fetch only set the cookie of Response-Cookie, none of the Request-Cookie.

from isomorphic-fetch.

luckydrq avatar luckydrq commented on June 9, 2024

isomorphic-fetch only set the cookie of Response-Cookie, none of the Request-Cookie.

@freestyle21 i still got puzzled. According what you said, isomorphic-fetch should save cookies set by server successfully. Related issue: koajs/koa#689

from isomorphic-fetch.

qubaomingg avatar qubaomingg commented on June 9, 2024

@luckydrq when we use isomorphic-fetch to send an HTTP GET Request,it cannot carry browser cookie to Request Header only if we set option {credentials: 'same-origin'}

here is the document: https://github.com/github/fetch#sending-cookies

from isomorphic-fetch.

luckydrq avatar luckydrq commented on June 9, 2024

yes, i've read that section. But what this issue addresses is how to save cookies to browser, it's about receiving not sending, am i right?

from isomorphic-fetch.

qubaomingg avatar qubaomingg commented on June 9, 2024

maybe isomorphic-fetch set credentials by empty or other value default.

and the document has said :

`To automatically send cookies for the current domain, the credentials option must be provided`

https://github.com/github/fetch#sending-cookies

I think this is weird too.

from isomorphic-fetch.

luckydrq avatar luckydrq commented on June 9, 2024

Alright, i'll keep on studying on this. If you find any detail please let me know. Thanks :D

from isomorphic-fetch.

skyFi avatar skyFi commented on June 9, 2024

i have a same problem...

from isomorphic-fetch.

firemanxx avatar firemanxx commented on June 9, 2024

Same problem, anyone has a s solution? That should be much appreciated.

from isomorphic-fetch.

tiendq avatar tiendq commented on June 9, 2024

My fetch request strangely returned 302 code then I found that it didn't include cookies so not authenticated properly on the server.

{ credentials: 'same-origin' } works.

from isomorphic-fetch.

vctt94 avatar vctt94 commented on June 9, 2024

Same problem, anyone with a solution? I'd appreciate

from isomorphic-fetch.

0t3dWCE avatar 0t3dWCE commented on June 9, 2024

Have just solved. Just two f. days of brutforce

For me the secret was in following:

  1. I called POST /api/auth and see that cookies are successfully received.
  2. Then calling GET /api/users/ with credentials: 'include' and got 401 unauth, because of no cookies were sent with the request.

The KEY is to set credentials: 'include' for the first /api/auth call too.

from isomorphic-fetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.