Nodemon server not working in CRA which deployed on Heroku
I have created an express server for my react application which is working fine on localhost. But when I deployed on heroku, the data from server not getting . Instead I getting this error in console.
I hope this is not an issue with Syntax but something with path. Uploading my server.js as well which is inside the root of application
const express = require('express');
const path = require('path')
const getDetails = require('./mock-data/topCompaniesInCity'); //added this things only for testing, we can use this structure to serve multiple data via this file
const getMajorIndustry = require('./mock-data/majorIndustryMockData');
const getCompanies = require('./mock-data/companies');
const app = express();
const port = process.env.PORT || 5000;
// console.log that your server is up and running
app.listen(port, () => console.log(`Listening on port ${port}`));
// An api endpoint that returns a short list of items
app.get('/api/getList', (req, res) => {
var list = ["item1", "item2", "item3"];
res.send(list);
console.log('Sent list of items');
});
// An api endpoint that returns a short list of items
app.get('/api/top-8-comapnies-in-cities', (req,res) => { //added this things only for testing, we can use this structure to serve multiple data via this file
var list = getDetails();
res.send(list);
console.log('Sent treasure');
});
//serving data of sectors along with number of comanies under that category
app.get('/api/major-industry', (req,res) => { //added this things only for testing, we can use this structure to serve multiple data via this file
var list = getMajorIndustry();
res.send(list);
console.log('Sent list of major industry');
});
//serving data of sectors along with number of comanies under that category
app.get('/api/companies-list', (req,res) => { //added this things only for testing, we can use this structure to serve multiple data via this file
var companies = getCompanies();
res.send(companies);
console.log('Sent list of companies');
});
if (process.env.NODE_ENV === 'production') {
// Serve any static files
app.use(express.static(path.join(__dirname, 'build')));
// Handle React routing, return all requests to React app
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
}
Attaching root of my application
I hope question is clear. Any kind of help would be great
Thank you