Search code examples
htmlherokucreate-react-applocal

Part of my website not rendering when pushed to heroku


I have a part of my website (react-app) that wont render when pushed to heroku, but it runs fine locally. The heroku domain is https://notmicahclark.herokuapp.com/

it uploads successfully to heroku no errors

my repo is https://github.com/Scharite13/NotMicahClark.

the page is the /art page.

the code related to it is the art.js file and the images are in the public, and the object is on art_database.js


Solution

  • enter image description here

    You've generated your build folder once. You've since done changes to your code but haven't generated a new build.

    const express = require("express");
    const app = express();
    const port = process.env.port || 5000
    app.use(express.static(path.join(__dirname, 'build')));
    app.get('/*', (req, res) => {
      res.sendFile(path.join(__dirname, 'build', 'index.html'));
    });    
    app.listen(port, () => console.log(`Server started on port: ${port}`));
    

    here you can see that you are only serving the content which is in your build folder. It hasn't changed.

    Go into your clients folder and execute npm build and move the generated build files into /build.