Carmelo Anthony (FoolishAzazel)
Carmelo Anthony (FoolishAzazel)
RRailway
Created by Carmelo Anthony (FoolishAzazel) on 10/27/2023 in #✋|help
Express Server With MongoDB 404 Accessing API
I have an Express server to host a react build file/folder and create api routes for get and post requests. I have setup a mongodb service and a repo (the express + build) and have connected the mongohost, pass, etc variables in the repo service. However, I recieve 404 errors when trying to access the API in my app/build Request URL: https://from-below-studio-react-production.up.railway.app/api/login Request Method: POST Status Code: 404 Not Found Here is my connection file for the db if (process.env.NODE_ENV === 'production') { const mongoUser = process.env.MONGOUSER; const mongoPassword = process.env.MONGOPASSWORD; const mongoHost = process.env.MONGOHOST; const mongoPort = process.env.MONGOPORT; connectionString = mongodb://${mongoUser}:${mongoPassword}@${mongoHost}:${mongoPort}; } else { connectionString = 'mongodb://127.0.0.1:27017/from-below'; } in my server.js where db is the connection file above: db.once("open", () => { httpServer.listen(PORT, () => {}); }); I copied an express mongo template to poke around and saw the api looks like this Request URL: https://mongo-express-production-a41d.up.railway.app/db/admin/ Request Method: GET Status Code: 304 Not Modified What am I missing here?
12 replies