Cant figure out my heroku app issue

Here is the link to my github repo: https://github.com/syne612/projectIcarusWebsite
Im not sure what the issue is.

the server/app file in the root directory is not used to start the app. check the package.json file for entry point

Hi, in local its working?
I didnt see you generated the static file for heroku in the index, its normal? I m on my mobile I cannot find for you now but I ll send u after if you want.

1 Like

yea that would be great.
Im new to deployment. this is actually my first attempt to deploy an app.

Ok Add this:
const path = require(‘path’);

app.use(express.static(path.join(__dirname, ‘client/build’)));

app.get(’*’, (req, res) => {

res.sendFile(path.join(__dirname+’/client/build/index.html’));

});

1 Like

I recommend you highly also to compress your bundle, the performance will be much higher:

const compression = require(‘compression’)

app.use(compression())

Next time you create an app you could use create-react-app, this way to connect server and front end you just need to create a proxy like this: “proxy”: “http://localhost:5000/” on the package.json of client (port must be the same as on server).

Also, If you use dotenv, dont forget to install the package + to require it: require(‘dotenv’).config();
But if you deploy on heroku, you dont need it as you can directly include the variable on heroku

Oups i almost forget something important:
add “heroku-postbuild” in your package.json

on my package I have this: “heroku-postbuild”: “cd client && yarn && yarn run build”
Concerning your project, I guess you can try this: “heroku-postbuild”: “build”

hey ok so let me first say thanks for the help so far. second where should i add the code from your first post of these 3? the one that starts with const path? should these go in my index.js file? part of the issue with this is that i was using a template/ UI kit for this. thats why the code is so “janky”. Ive even debated rebuilding this on my local machine using my own variation packages and server set ups (“create-react-app”) and then just copying the components files. part of the issue is the way the css is built in this. its done in react which is making changing code around a bit of a pain.