Navigating the Same Origin Policy

Hey, I’m Ashley! I’ve very recently learnt about Blockstack and I’m pretty excited about the project. The first thing I wanted to do was write an app that fetches user-entered RSS feeds. While I haven’t use React much, this seemed fairly simple. Immediately though I ran right into the following:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <URL>. (Reason: CORS request did not succeed).

It seems that quite a lot of the RSS feeds I’d like to access don’t set this Access-Control-Allow-Origin header. A solution I’ve posted online is to run a server that requests these restricted resources for you, but that doesn’t exactly fit with the ideas of decentralisation and scalability.

What do you guys suggest I do? The only thing I can think of at the moment would be to create an electron app instead of a web app, but I really don’t want to make users download a copy of chromium just to use what should be a pretty simple app. is an rss reader which fetches the content of one or more user-entered RSS feeds. For a while, we had it set up to attempt a fetch assuming a cors browser plugin then fall back to the cors relay you suggested (see code below). We didn’t like that approach, so our next iteration will use your suggested centralized cors relay, but offer a place for the reader to enter their own cors relay address. Perhaps with localhost:1337 being default - maybe instructions how to set that address up.

let Parser = require('rss-parser')
let parser = new Parser()
var memoize = require("memoizee")

const slow_fetchFeedContent = feedUrl => {
  return !feedUrl ? 
  Promise.reject('slow_fetchFeedContent requires feed url') :
  parser.parseURL(feedUrl)  // should only work with a browser cors plugin
  .catch((error) => {
    parser.parseURL(`/.netlify/functions/node-fetch?url=${feedUrl}`) // cors relay
const fetchFeedContent = memoize(slow_fetchFeedContent, { promise: true, maxAge: 10000 })

this is all very complicating

Ah, that’s an acceptable solution for now, thanks!

1 Like