-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Fixing http adapter to allow HTTPS connections via HTTP #959
Fixing http adapter to allow HTTPS connections via HTTP #959
Conversation
e6c944f
to
486c956
Compare
@mzabriskie When is this going to get merged and released? I need it for a project I'm working on and will need to move to something else if it's not going to be soon |
Implemented changes from axios#959
Please merge this, for now, we have to use the contentful |
Please remove all changes relating the package.json and the generated files in |
index.d.ts
Outdated
@@ -14,6 +14,7 @@ export interface AxiosBasicCredentials { | |||
export interface AxiosProxyConfig { | |||
host: string; | |||
port: number; | |||
isHttps?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use a protocol
option instead, accepting both http
and http:
formats so parsed URL can be passed as the proxy option.
lib/adapters/http.js
Outdated
@@ -118,13 +118,14 @@ module.exports = function httpAdapter(config) { | |||
} | |||
|
|||
var transport; | |||
var useHttps = isHttps && (proxy ? proxy.isHttps : true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use isHttpsProxy
instead as it's clearer.
Please merge this, I need this behavior for my project. I switched to axios from request.js recently. I don't wanna do any doubts/ in my decision. |
486c956
to
e9a9c62
Compare
<3 |
Please merge this, i need this for a project that i working on. |
Can we get this merged? We're also having issues with this, and are using a fork for now. |
FWIW: It would be excellent to see this merged in sometime :) |
Doesn't fix the real problem for me. Instead, fails with a nicer (and faster) error:
|
@mrchief are you trying to connect to an HTTP endpoint through an HTTPS proxy? Do you have a small code snippet that fails? |
@zcei I was using Fiddler proxy. I set it up to decrypt HTTPS traffic so that it listens for https requests. I don't have any small snippet but it should be reproducible fairly easily by:
The request should fail with above error. |
@mrchief Did you pass it like this literal value? |
Tried passing it as
|
It seems passing it on the
I was trying to set it on the instance before:
The readme indicates that the same config can be used (for It might help to separate them if that's the case, i.e create config is not the same as request config. The same thing without your patch gives me this error: So I guess your patch does work! :) |
@mrchief thanks for the additional info! 🙏 The Glad you faced it, though, so other people can refer to your findings in case they face it as well. |
Summary
We are using axios at Contentful for both our JS SDKs contentful.js and contentful-management.js.
Axios was assuming always that the
proxy
protocol is the same as the URL it is requesting. This a problem when you use ahttp
proxy when requesting data fromhttps
endpoint.see more at #925 and #753
Purpose of the PR
This PR make
httpAdapter
to allow https connections via http by introducing a new config param to theproxy
object calledisHttps
which defaults to falseTODO