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.

Cross Origin Request Blocked

See original GitHub issue

What I Wanted DatArchive.load and read file per https://github.com/datproject/sdk#apiexamples-promise

What I Did

index.js:

// Auto-detects sane defaults based on your environment
// Uses Beaker's APIs if they are if they are available
// DatArchive is the same as Beaker
// https://beakerbrowser.com/docs/apis/dat
const { DatArchive } = require("dat-sdk/auto");

(async function() {
  const archive = await DatArchive.load("dat://dat.foundation");

  const someData = await archive.readFile("/dat.json", "utf8");

  console.log("Dat foundation dat.json:", someData);
})();

browserify -d index.js > test-bundle.js

index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="/test-bundle.js" defer></script>
  </head>
  <body>
    <div></div>
  </body>
</html>

What I Got

Firefox console output: TypeError: NetworkError when attempting to fetch resource. Firefox can’t establish a connection to the server at ws://localhost:3472/. stream.js:64 Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://gateway.mauve.moe/undation/.well-known/dat. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

TypeError: NetworkError when attempting to fetch resource.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
urgentcommented, Oct 8, 2019

Yes that 3 second wait worked great. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Ways to Fix the CORS Error — and How the Access-Control ...
If the frontend domain does not match the value, the browser raises the red flag and blocks the API request with the CORS...
Read more >
Firefox 'Cross-Origin Request Blocked' despite headers [closed]
I came across this question having found requests in Firefox were being blocked with the message: Reason: CORS request did not succeed.
Read more >
CORS errors and how to solve them - Topcoder
Why is CORS blocked? ... It is to prevent cross-site request forgery. Let's say you log in to facebook.com and your browser stores...
Read more >
Cross-Origin Request Blocked: The Same ... - Microsoft Learn
If the CORS configuration isn't setup correctly, the browser console will present an error like "Cross-Origin Request Blocked: The Same Origin ...
Read more >
What Is a CORS Error and How to Fix It (3 Ways) - Bannerbear
To get rid of a CORS error, you can download a browser extension like CORS Unblock. The extension appends Access-Control-Allow-Origin: * to every...
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