Answer the question
In order to leave comments, you need to log in
How to run React on Heroku?
Writes that it cannot get GET (cannot get /). I already did build and indicated ..
const express = require('express');
const config = require('config');
const mongoose = require('mongoose');
const path = require('path');
const app = express();
app.use(express.json({ extended: true }));
app.use('/api/auth', require('./routes/auth'));
app.use('/api/search', require('./routes/search'));
app.use('/', express.static(path.join(__dirname, 'client/build')));
const PORT = process.env.PORT || 5000;
async function start() {
try {
mongoose.connect(config.get('mongoUri'), {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
});
app.listen(PORT, () => console.log(`Running on ${PORT}`));
} catch(e) {
console.log('Server Error', e.message);
process.exit(1);
}
}
start();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question