express routes returning 404

joshdobbsTRIAL

a year ago

I have a NodeJS app using Sequelize, PostgreSQL and typescript.
I have my routes

Solved

3 Replies

joshdobbsTRIAL

a year ago

My routes are set up in 2 separate files:

  • routes/index.ts

  • routes/user.ts

All of the routes are accessible from on my dev environment however when I deploy to Railway, all of the requests I make to any of the /user routes return a 404 error.

This is one of the endpoints: timetoplant-production.up.railway.app/user/test.
When I make a post request via postman I get an error that states Cannot GET /user/test which is confusing me because I'm not making a get request and the route is set up to use a post request.

This is the only error i'm seeing in the logs:
::ffff:192.168.0.3 - - [12/Feb/2024:03:48:27 +0000] "GET /user/test HTTP/1.1" 404 148 "http://timetoplant-production.up.railway.app/user/test"; "PostmanRuntime/7.36.1"

Does anyone know what could be causing this?

This is the code that sets up the routes:

```typescript
app.use(bodyParser.json()) // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true }))
// import { plants } from './seeders/plants';

app.use(express.static(path.join(__dirname, 'public')));

const indexRouter = require('./routes/index');
app.use('/', indexRouter);

const userRoutes = require('./routes/user');
app.use('/user', userRoutes);


a year ago

please make sure you are using https when calling your api


Status changed to Solved railway[bot] about 1 year ago


joshdobbsTRIAL

a year ago

Thanks! That did the trick.


express routes returning 404 - Railway Help Station