Skip to content
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 protocol https not found issue #1904

Merged
merged 2 commits into from Dec 25, 2019
Merged

Fixing protocol https not found issue #1904

merged 2 commits into from Dec 25, 2019

Conversation

M-shin
Copy link
Contributor

@M-shin M-shin commented Nov 30, 2018

Fixes #768

Axios determines isHttpsRequest based on the protocol in the url. So for urls beginning with http://, it will try to use an httpAgent. Then, if the url internally redirects to https, it throws the "Protocol https not supported" error in the issue above. This only happens when a custom httpAgent is supplied to axios.

To fix, we just need to pass both agents to follow-redirects and let that package choose based on what protocol it encounters https://github.com/follow-redirects/follow-redirects/blob/v1.4.1/index.js#L121

@mattlyons0
Copy link

Nice fix! Would it be better to add the agents key to options after this line?

transport = isHttpsProxy ? httpsFollow : httpFollow;

That way it will only be added if the follow-redirects package is being used?

Copy link

@kazi-sabbir kazi-sabbir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the change and found working.
Test URL that redirects from https to http : https://www.thinkadvisor.com/search/?q=insure

@webjohnjiang
Copy link

mark

freearhey added a commit to freearhey/iptv-checker that referenced this pull request Aug 17, 2019
Known issue: `Protocol "http:" not supported. Expected "https:"`.
More details: axios/axios#1904 (comment)
@axios axios locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Protocol "https:" not supported. Expected "http:" Error
8 participants