Skip to content

Conversation

@hamano
Copy link

@hamano hamano commented Jun 9, 2022

Hi, I found a weired issue.
rss-parser does not fetch feed that is hosted github.io with Firefox, but no problem with Chrome.
github.io responds Access-Control-Allow-Origin: * as expected.
The cause was that Firefox was sending a CORS preflight request.
There are several conditions for sending a preflight request, one of which is User-Agent changing.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#examples_of_access_control_scenarios

I think many people will be bothered by this issue, so
I recommend not to set User-Agent by default.

@rbren
Copy link
Owner

rbren commented Jun 15, 2022

Hmm. If I remember correctly, when running server-side, we need to add a User-Agent header for a lot of feeds to work. So this could be a breaking change.

Does passing in the option {headers: {'User-Agent': ''}} reset to using the browser's user agent?

@hamano
Copy link
Author

hamano commented Jun 22, 2022

@rbren thanks for the reply.
I tryied: {headers: {'User-Agent': ''}} and {headers: {'User-Agent': null}} but they didn't works.
I've put test file here, please try with Firefox: https://www.osstech.co.jp/~hamano/test.html

@rbren
Copy link
Owner

rbren commented Jun 22, 2022

OK, I think this might be a better solution (untested pseudocode):

let headers = { 'User-Agent': 'rss-parser', } if (typeof window !== 'undefined' && window.navigator && window.navigator.userAgent) { headers['User-Agent'] = window.navigator.userAgent; }

This way we won't create a breaking change for server-side rss-parser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants