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.

`credentials` config not supported in node?

See original GitHub issue

Describe the bug

When I set the credentials config in fetch to 'omit' that isn’t passed along to the req.

Environment

  • msw: 0.0.18
  • nodejs: 12
  • npm: 6.14.5

To Reproduce

https://github.com/kentcdodds/bookshelf/commit/b733434fbfbef5d8d67aca15a444c9b063437615#diff-47664a78a0147eab6cc64883365d1ef4R75-R76

test('allows for config overrides', async () => {
  let request
  const endpoint = 'test-endpoint'
  const mockResult = {mockValue: 'VALUE'}
  server.use(
    rest.get(`${apiURL}/${endpoint}`, async (req, res, ctx) => {
      request = req
      return res(ctx.json(mockResult))
    }),
  )

  const customConfig = {
    credentials: 'omit',
    headers: {'Content-Type': 'fake-type'},
  }

  await client(endpoint, customConfig)

  // TODO: this should pass but it's not...
  // expect(request.credentials).toBe(customConfig.credentials)
  expect(request.headers.get('Content-Type')).toBe(
    customConfig.headers['Content-Type'],
  )
})

Expected behavior

I expect the request.credentials to bet set to what is set in the window.fetch call.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
kentcdoddscommented, Jun 4, 2020

Interesting! In any case, it seems that this is out of scope for this module and it’s actually up to the polyfill to deal with this.

Also, it’s not critically important to me anyway so I’ll go ahead and just close this.

Thanks for the discussion everyone 😃

1reaction
kimroencommented, Jun 4, 2020

What they are doing that might be debated though, is assuming same-origin (the default) means “don’t include the credentials ever”, but that has already been discussed fairly extensively over here: https://github.com/whatwg/fetch/pull/585

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing credentials in config, if using AWS_CONFIG_FILE, set ...
When using credentials in plain text everything works good but when I am trying to use environment variables it's not working. Error message....
Read more >
Setting Credentials in Node.js - AWS SDK for JavaScript
Credentials that are obtained by using a credential process specified in the shared AWS config file or the shared credentials file. For more...
Read more >
Loading Credentials in Node.js from a JSON File - 亚马逊云科技
You can load configuration and credentials from a JSON document on disk using AWS.config.loadFromPath . The path specified is relative to the current ......
Read more >
Credentials Configuration - NodePit
In such cases (resetting and) executing a downstream node will fail as the password is not part of the credentials object passed from...
Read more >
@aws-sdk/credential-provider-node - npm
If invalid configuration is encountered (such as a profile in ~/.aws/credentials specifying as its source_profile the name of a profile that does not...
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