pexels / pexels-javascript

Official Javascript library for the Pexels API.
https://www.pexels.com/api/documentation/
148 stars 29 forks source link

Fails to query in Firefox due to CORS #45

Open ishanray opened 1 year ago

ishanray commented 1 year ago

When trying to use this library in Firefox, it fails with:

Screenshot 2023-02-16 115209

Seems like this is being caused by trying to change the User-Agent while creating the fetch wrapper.

The reason it works in Chrome is because Chrome doesn't allow overriding of the User-Agent due to this longstanding bug

Request headers in Firefox:

Screenshot 2023-02-16 115048

Request headers in Chrome:

Screenshot 2023-02-16 115018

The fix would be to simply add User-Agent on the server side CORS config or delete this line from the library since Chrome users are not using this right now.

I verified it works in Firefox if that line is deleted. I can open a patch if required.

bosskabouter commented 1 year ago

I am seeing the same issue here. FF 109.0.1

nourmalaeb commented 1 year ago

I am also seeing this issue, both in Firefox as well as Safari on a Mac.

gillisig commented 1 year ago

Same

filmboard-io commented 1 year ago

Encountering same issue. Hopefully Pexels solves this soon

peter-writes-code commented 1 year ago

@ishanray has it on the lock down. We are both more than glad to submit a patch.

In the meantime my trivial workaround was to use axios (or fetch) instead of the provided JS client, and it now works in all browsers.