question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v3] Add credentials to RequestInit

See original GitHub issue

Is your feature request related to a problem? Please describe.

node-fetch’s request type does not include credentials: https://github.com/node-fetch/node-fetch/blob/cbd4d895767e33491219e40013dd8daa5c7ac024/%40types/index.d.ts#L56

This is a field provided by the web platform: https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials

Describe the solution you’d like

Add credentials field

Describe alternatives you’ve considered

I could work around it, but would prefer not to have to

Additional context

This is used in the upcoming SvelteKit: https://github.com/sveltejs/kit/blob/95c47bcdb884194359475968b1e0eeb342820611/packages/kit/src/runtime/server/page/load_node.js#L129

SvelteKit’s predecessor Sapper did something similar as well: https://github.com/sveltejs/sapper/blob/339c417b24e8429d3adc9c9f196bf159a5fce874/runtime/src/server/middleware/get_page_handler.ts#L137

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jimmywartingcommented, Jan 17, 2022

the only thing we could support is the omit the other two (same-site and include) would have the same meaning on backend

So there is a tiny usecase for it… but since we don’t have a cookie jar either… then it have even less usefulness

0reactions
benmccanncommented, Jan 25, 2022

We don’t want things to work on the server-side and then break on the client-side because it’d be very difficult for users to see different behavior depending on whether they did a server-side or client-side navigation to the page. All we were requesting here was to change the type so that we can check if (opts.credentials !== 'omit') ourselves without running into an issue of credentials not being defined on the type. I wasn’t suggesting to change the node-fetch behavior

Let’s leave the SvelteKit discussion in that repository to avoid confusing this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

RequestInit | typescript - v3.7.7
A string indicating how the request will interact with the browser's cache to set request's cache. Optional credentials. credentials: RequestCredentials.
Read more >
How to make request body type compatible with RequestInit or ...
You need to stringify your body: let params: RequestInit = { headers: headers, method: "PUT", body: JSON.stringify(body) }.
Read more >
Setting credentials - AWS SDK for JavaScript
Credentials can be set per service, by passing credentials directly to a service object. There are several ways to set credentials that differ...
Read more >
Advanced HTTP networking - Apollo GraphQL Docs
The following example demonstrates adding a custom link to Apollo Client. ... 3. const httpLink = new HttpLink({ uri: '/graphql' });.
Read more >
Request.credentials - Web APIs | MDN
Always send user credentials (cookies, basic http auth, etc..), even for cross-origin calls. This is similar to XHR's withCredentials flag, but ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found