I have a nearly-fresh create-react-app
project where I've got a simple express server running a test API endpoint:
const express = require('express');
const app = express();
if(process.env.NODE_ENV === 'production') {
app.use(express.static('build'));
}
const port = process.env.PORT || 5000;
app.get('/api/hello', (req, res) => {
res.send('Hello From Express');
});
app.listen(port, () => {
console.log(`Server started at: http://localhost:${port}/`);
});
In package.json
I've added a line, "proxy": http://localhost:5000",
and it all works fine locally. However when I deploy to Heroku I get 'Invalid Host Header'. How can I change this to work in production?