News for hackers. Stuff that matters.
Re:How do dat:// sites interact with servers? by pfraze on Tuesday June 12, 2018 @02:18PM (#17296216)
I'd be happy to be corrected on this, but here's what I understand:

While fetch doesn't preflight for GET, it does require an Access-Control-Allow-Origin header. You can specify `no-cors` in the mode to circumvent this, but then you cant access the response body (https://developer.mozilla.org/en-US/docs/Web/API/Request/mod...)

Re:How do dat:// sites interact with servers? by panarky on Tuesday June 12, 2018 @02:31PM (#17296394)
Here's an example using your own site.

Open the console in an empty Chrome window and paste this:

  fetch('https://pfrazee.hashbase.io/feed.xml')
    .then(response => response.text())
    .then(str => console.log(str))
You'll get your RSS feed, no CORS tricks required.
Re:How do dat:// sites interact with servers? by pfraze on Tuesday June 12, 2018 @02:35PM (#17296436)
My site has the Access-Control-Allow-Origin:* header set. Try the same thing on the Beaker site in the devtools for https://example.com.

    fetch('https://beakerbrowser.com/dat.json')
      .then(response => response.text())
      .then(str => console.log(str))
It should fail
Re:How do dat:// sites interact with servers? by bhritchie on Tuesday June 12, 2018 @03:30PM (#17297112)
It is failing for me because of the content security policy, which is a different thing.
Re:How do dat:// sites interact with servers? by pfraze on Tuesday June 12, 2018 @03:56PM (#17297380)
That's the case on HN. Example.com doesnt have CSPs setup so it's CORS that causes the issue.