1

I've created a backend with Node.js and I've gone through Heroku's Node.js troubleshooting guide with no luck.

This is what I get when I try to hit /items:

2021-12-22T00:00:31.281188+00:00 heroku[router]: at=info method=GET path="/items" host=react-native-backend-vw.herokuapp.com request_id=fe7f509e-dffc-41dd-831e-13bc20c2a7fa fwd="69.143.59.34" dyno=web.1 connect=0ms service=15ms status=500 bytes=292 protocol=https

This is what I get when I try to create an item:

2021-12-22T00:42:36.215687+00:00 heroku[router]: at=info method=POST path="/" host=react-native-backend-vw.herokuapp.com request_id=a51e95c8-1bc4-41f0-ba95-108ab64f0ed9 fwd="69.143.59.34" dyno=web.1 connect=0ms service=42ms status=500 bytes=292 protocol=https

As you can see I'm getting a status 500 for them with no other errors.

server.js:

if (process.env.NODE_ENV !== 'production') { 
require('dotenv').config() }
const express = require("express");
const app = express();
const cors = require("cors");
const bodyParser = require("body-parser");
const itemsRouter = require("./routes/items-router");

app.use(express.json());

app.use(cors());

app.use(bodyParser.urlencoded({
    extended: true
}));
app.use(bodyParser.json());

app.use('/', itemsRouter);

app.listen(process.env.PORT || 3001);

app.use((err, req, res, next) => {
    res.status(500).json({
        message: "Something went wrong",
    });
});

module.exports = app

knexfile.js:

module.exports = {

  development: {
    client: "pg",
    connection: {
      host: process.env.HOST,
      user: process.env.USER,
      password: process.env.PASSWORD,
      database: process.env.DATABASE,
      charset: "utf8"
    },
    migrations: {
      directory: __dirname + "/knex/migrations",
    },
    seeds: {
      directory: __dirname + "/knex/seeds"
    }
  },

  production: {
        client: "pg",
        connection: process.env.DATABASE,
        migrations: {
            directory: "./knex/migrations",
        },
        seeds: {
            directory: "./knex/seeds",
        },
        pool: {      
            min: 2,      
            max: 10    
        }
    }

};

I've spent many hours and looked at every resource. Any help offered would be super appreciated!!!

0 Answers0