Ask coding questions

← Back to all posts
How do you check if a repl exists?
firefish (914)

EDIT: I have found the answer by myself.

Here is a cut-down version of my code:

const f = require("node-fetch");

(async () => {
  await f("https://repl.it/@a/b")
    .then(res => console.log(res.status));
  await f("https://repl.it/@firefish/haha-fetch-go-brrr")
    .then(res => console.log(res.status));
})();

Now, I am testing to see if a repl is private or not. I am expecting the output

404
200

but instead I get

403
403

Upon extracting the body of the response, I can see that it is the HTML of Cloudflare Error 1020 (which I happen to have an old screenshot of when repl.it showed the same error to everybody temporarily).

I can wget it from both repl.it and my host machine.

Otherwise, how do you check if a repl exists, or is private/non-existant?

Comments
hotnewtop
firefish (914)

Ok, I found the answer to my own problem. It was the fact that the user agent being passed by node-fetch was deemed "untrustworthy", so all I had to do was replace the user agent with something as simple as Mozilla/5.0 and that did the trick.

Kookiez (386)

There's 0 answers yet 4 upvotes. i bet amasad can answer this

firefish (914)

@Kookiez ok i answered my own problem

firefish (914)

@Kookiez because you are now part of the project, you are entitled to work on it

Kookiez (386)

@firefish oh noes, i am supposed to work 2 hours a day on a multiplayer repl and on this while doing my own thing that i work 30 min a day and trying to catch up on schoolwork at the same time! yay? lol

firefish (914)

@Kookiez ok lol maybe not then i'll find someone else FOR THE TIME BEING ;)