Implement Isomorphic fetch so it works for browsers
See original GitHub issueHey, thank you for this wonderful package.
I know this is a Node JS package but can it be used from the frontend like React?
I’m currently making a Chrome extension where I need to get metadata of any site specified so I did this -
import unfurl from "unfurl";
_fetchMeta = async () => {
try {
let result = await unfurl("https://akshaykadam.me");
console.log("result", result);
alert(result);
} catch (e) {
console.error("e", e);
}
};
But I get this error -
Failed to load https://akshaykadam.me/: No 'Access-Control-Allow-Origin' header is present on the
requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque
response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS
disabled.
e TypeError: Failed to fetch
In Chrome Extension, it can be removed by adding "permissions": ["<all_urls>"]
so I did that but still doesn’t work.
It should work as written here 👇
Source:
Find Cross-Domain from Chrome Extensions
in CORS tutorial
I also tried running it as a Web App but still same error. So my question is it possible to do this from Frontend?
Issue Analytics
- State:
- Created 5 years ago
- Comments:37 (13 by maintainers)
Top Results From Across the Web
isomorphic-fetch - npm
This module will enable you to use fetch in your Node code in a cross-browser compliant fashion. The Fetch API is part of...
Read more >Polyfilling the Fetch API for Old Browsers and Node.js
First some definitions. A polyfill will try to emulate certain APIs, so can use them as if they were already implemented. A transpiler...
Read more >Comparing CrossFetch Vs Axios Vs Isomorphic Fetch Vs ...
As the name implies, isomorphic-fetch works for both NodeJs and within the browser. isomorphic-fetch is a polyfill module rather than a pony- ...
Read more >isomorphic-git · A pure JavaScript implementation of git for ...
isomorphic -git is a pure JavaScript implementation of git that works in node and browser environments (including WebWorkers and ServiceWorkers).
Read more >What is the difference between isomorphic-fetch and fetch?
While isomorphic-fetch is implementation of fetch for both node.js and browser, built on top of fetch polyfill. Share.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ubershmekel Hi. That was because doing Unfurling in the browser is thwart with issues. Primarily it’s unfeasible due to CORS. Which you can get around if you proxy your requests - but at that point you may as well do the unfurl there too (i.e. server side).
I saw this change https://github.com/jacktuck/unfurl/commit/76cab79ec1fbc02e9e3e2e928d224c4c52b8a26b that states browsers won’t be supported. Why is that the case @jacktuck ?