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

Support browser extensions #106

Closed
lmk123 opened this issue Oct 19, 2022 · 4 comments
Closed

Support browser extensions #106

lmk123 opened this issue Oct 19, 2022 · 4 comments

Comments

@lmk123
Copy link

lmk123 commented Oct 19, 2022

The documentation says that this project cannot be used in browsers because of CORS, but in fact browser extensions allow cross-domains.

I hope this project can support use in browser extensions, theoretically just by replacing got with axios.

@vitalets
Copy link
Owner

In the latest beta release I've replaced got with node-fetch, that actually should work in browser context.
I would appreciate if you try it and share the result!

@lmk123
Copy link
Author

lmk123 commented Oct 19, 2022

Thanks for your work!

node-fetch seems to be supported only in Node.js. Its homepage says this:

See Jason Miller's isomorphic-unfetch or Leonardo Quixada's cross-fetch for isomorphic usage (exports node-fetch for server-side, whatwg-fetch for client-side).

But isomorphic-unfetch has not been updated for two years, and cross-fetch is still using the v2.x version of node-fetch.

Probably axios is still the better solution.

@vitalets
Copy link
Owner

I've used node-fetch v2 that has browser field in package.json and bundler (webpack) should correctly use built-in fetch.
Also found interesting discussion in node-fetch repo node-fetch/node-fetch#786

@vitalets
Copy link
Owner

Just checked new v9 - it works in browser extensions.
Added documentation to readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants