Skip to content

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