Ask coding questions

← Back to all posts
Trying to connect to another Repl webserver only gets to repl.co (not subdomain) and returns 404
WeirdAlex03

I'm working on a project that requires having the database in a separate project. Both are Node.js projects using the http module. The database project works fine and receives data from a third script attached to a Google Form, but it can't get requests from the frontend project (attached) through http.get. The frontend receives 404 Not Found but the database shows no activity.

Upon further investigation, I found the problem is that instead of correctly sending the request to the database at Classmate-Finder-Database.weirdalex03.repl.co, it gets stuck at just repl.co, which always returns 404.

Trying to query the database by navigating there in a normal browser gives the expected results, but that's useless when the project can't connect. What is going wrong? Is there a way to get it to connect to the proper subdomain to actually reach the database? Would connecting the database project to another domain work? Do I need to go back to the drawing board and seriously reconsider how this works?

The frontend code is in index.js and the database code is in databaseServer.js. They share a GH repo so they have the same files, but they are run in two separate Replit projects through different .replit configs.

* Note the database currently 405 for not found, that was just to distinguish from the database's response and repl.co's 404, you can ignore that.