← Go Back

RxJS Error: CORS is not supported by your browser

Broken Post?Let me know

This is a note-to-self/devjournal to keep track of the issue I ran into.
Just rephrasing a StackOverflow answer but come back and find easily.

I was playing around with RxJS and ran into following error on

Error: CORS is not supported by your browser

Can reproduce it here

A quick google search returned a StackOverflow question, Using rxjs ajax() I get “CORS is not supported by your browser”.

Ben Lesh(creator of RxJS) replied that one needs to pass a custom XMLHttpRequest object.

import { XMLHttpRequest } from "xmlhttprequest"

function createXHR() {
  return new XMLHttpRequest()

const ajax$ = ajax({
  createXHR, // <--- here
  url: genURL_chan(179),
  crossDomain: true,
  withCredentials: false,
  method: "POST",
  body: { since: 0, mode: "Messages", msgCount: 5000 },

Now the node script below should work w/o an issue.

Image by Taco Fleur from Pixabay


Loading counts...

❤️ 0 💬 0
Fetching Replies...
There is no reply...