1

I deployed my website heroku, but when I refresh I get an internal server error,

this is my website: https://softeismachines.herokuapp.com/

I using express for my server:-

const express = require('./node_modules/express');
const bodyParser = require('body-parser');
const nodemailer = require('nodemailer')
const sendMail = require('./mail');
const sendEnquiry = require('./enquiry');
const compression = require('compression');
const morgan = require('morgan');
const { createServer } = require('http')
const app = express();
const dev = app.get('env') !== 'production';
const path = require('path');
const normalizePort = port => parseInt(port, 10);
const PORT = normalizePort(process.env.PORT || 5000);

if (!dev) {
app.disable('x-powered-by');
app.use(compression());
app.use(morgan('common'));

app.use(express.static(path.resolve(__dirname, 'build')));
app.get('*', (res, req) => {
    res.sendFile(path.resolve(__dirname, 'build', 'index.html'))
})
}

if (dev) {
    app.use(morgan('dev'))
}

app.use(bodyParser.json())
app.use(express.urlencoded({ extended: false }));
n.kilani
  • 41
  • 1
  • 2
  • 8
  • possible duplicate https://stackoverflow.com/questions/41772411/react-routing-works-in-local-machine-but-not-heroku and https://stackoverflow.com/questions/56131883/how-do-i-rewrite-all-urls-to-index-html-in-heroku – Afeef Janjua May 21 '20 at 10:29
  • I added a static.json file and it doesnt work – n.kilani May 21 '20 at 11:00

0 Answers0