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.

Contentful (axios) throws: TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"

See original GitHub issue

Environment

Name Version
msw 0.39.0
node v16.13.0
OS Windows 10

Request handlers

See a complete reproducible repo here. Just npm i and then node app.js.

Current behavior

Mocking a minimal get request to Contentful’s readonly API causes msw/NodeClientRequest.Client request to throw:

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"

…akin to previous issues, but something new must be going on here. Under the hood Contentful uses axios, which might shed some light on the cause. If I revert back to 0.36.8 this issue does not happen (but has its own set of issues).

Expected behavior

For msw to intercept the request successfully and return a mocked response.

Screenshots

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
arcoscommented, Mar 8, 2022

Just for other peoples’ future reference. This was a matter of passing node’s https.Agent() to the Contentful client param httpsAgent during instantiation. Thanks for your help @kettanaito.

0reactions
github-actions[bot]commented, Mar 8, 2022

🎉 This issue has been resolved in version 0.39.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node js Error: Protocol "https:" not supported. Expected "http:"
My project needs to request a JSON from an API, so I can use the data it provides. I use the http get...
Read more >
contentful.js - Documentation
contentful.js. /** * Contentful Delivery API SDK. Allows you to create instances of a client * with access to the Contentful Content Delivery...
Read more >
Node Js Error: Protocol "Https:" Not Supported ... - ADocLib
Please You can generate a new API key in the Cloud Console. TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:" at new NodeError ......
Read more >
@contentful/axios - npm
Promise based HTTP client for the browser and node.js. Latest version: 0.18.0, last published: 5 years ago. Start using @contentful/axios in ...
Read more >
Node js Error: Protocol "https:" not supported. Expected "http:"
I got this error while deploying the code. INFO error=> TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:" at ...
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