0

I am hosting postgres database and app on Heroku. Express Router was working on my local host. Since I have deployed to Heroku I get ERROR on index route. But URL routes work when typed in.

I have tried making sure the PORT is setup correctly. I have tried testing to see if Express/Router actually works by changing routes. I have tried the other answers on stack overflow. I have checked my proct file.

app.js

```
const express = require("express")
const app = express()
const path = require('path')
const PORT = process.env.PORT || 8080

const mustacheExpress = require("mustache-express")

const blogsRouter = require('./routes/blogs')

app.use(express.urlencoded({ extended: false }))

const VIEWS_PATH = path.join(__dirname, '/views')

app.use("/css", express.static(__dirname + '/css'))

app.engine("mustache", mustacheExpress(VIEWS_PATH + '/partials', '.mustache'))
app.set("views", VIEWS_PATH)
app.set("view engine", "mustache")

app.use('/blogs', blogsRouter)

app.listen(PORT, () => {
    console.log("Hey Nick the server is running...")
})```

blogs.js //Routes folder

```const express = require('express')
const router = express.Router()
const bcrypt = require('bcrypt')
const SALT_ROUNDS = 10
const session = require('express-session')
const checkAuth = require("../utils/checkAuth")

const pgp = require('pg-promise')();
const connectionString = '#postgress host string is here'
const db = pgp(connectionString);
```

Do not know whats causing Express Router not to work on Heroku.

0 Answers0