question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement Isomorphic fetch so it works for browsers

See original GitHub issue

Hey, 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:closed
  • Created 5 years ago
  • Comments:37 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jacktuckcommented, Jun 2, 2020

@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).

1reaction
ubershmekelcommented, Jun 2, 2020

I saw this change https://github.com/jacktuck/unfurl/commit/76cab79ec1fbc02e9e3e2e928d224c4c52b8a26b that states browsers won’t be supported. Why is that the case @jacktuck ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found