-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't read set-cookie headers from backend server properly #75
Comments
Hi, this is more about servers in general right? Im doing the following in our http middleware proxy in some totally other server code but i think it should help you looking how to proceed. And its simple :)
|
this is unpredictable as cookie value may contain |
Maybe first read about the cookie spec ...
"This string is a sequence of characters excluding semi-colon, comma and
white space. If there is a need to place such data in the name or value,
some encoding method such as URL style %XX encoding is recommended, though
no encoding is defined or required."
Op wo 27 jan. 2021 om 19:17 schreef Afzal Hossain <notifications@github.com
…:
this is unpredictable as cookie value may contain ,
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#75>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGGCHDH5A3POAPPS47CG5M3S4BKB3ANCNFSM4NEXQTTA>
.
|
Read a little bit further and you'll see there's expires=DATE where date contains a comma... so couple cookies joined with a , having optional expire value will case a problem expires=DATE Wdy, DD-Mon-YYYY HH:MM:SS GMT Of course it can be solved by some regex matching etc. |
Ah oke now you edit :) that makes my response weird indeed :) Hi Afzal, i will debug for you, since i have the code in production :) Internally i have:
|
Hey so I ran into this same issue. Conveniently enough the Apollo doesn't have the method typed so you'll have to augment the types or cast it to any. This worked for me: |
This is unfortunately not particularly fixable in a compelling way: we've chosen to orient this package around the Fetch API but the Fetch API does not let you differentiate between "a header showed up twice" and "the same thing but joined with comma-space". (This API was designed for browsers where it explicitly cannot see Set-Cookie headers!) Making RESTDataSource work with multiple Fetch implementations is a pretty key part of the design so we can't really rely on response.headers.raw() in our general implementation. If you're sure you're using node-fetch then you can do what @cjonesdoordash showed and use What I'd like to do is add a test that if you send a POST (with the default |
I'm using apollo server as an orchestration layer which connects and gets data from other backend servers.
I need to forward the set-cookie headers from backend server. Works well if there's one set-cookie header but if there are multiple there's a problem.
return type for
response.headers.get
is string | null but in this case it should be array.if we console log
response.headers
we see that inside Symbol map the set-cookie header is actually an array but gets converted to string when trying to get the value using the get method.Couldn't find a way to get the original array.
The text was updated successfully, but these errors were encountered: