I've been attempting to deploy a react-app in Heroku for a while now, and every tip on the internet tells me to use Buildpack for create-react-app, but that build pack is now outdated and no longer supports the heroku-22 stack.
I attempted to deploy the app using the node-js-buildpack, but was unable to do so. My Heroku procfile has the following command: web: npm install -g serve && serve -s build, however as you can see, it only delivers a static version, not a dynamic one.
The package.json react scripts I have are this ones:
"scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" },
The npm serve instructions allow me to access the website, but unlike my localhost one, it does not display the updated data when fresh data is received. In addition, in my development version, I use yarn as a package manager.
The app runs like so:
I have some PostgreSQL triggers that inform me when data is insert or edited on specific tables, and then I supply the API server with the table name that was changed.
I get it on my node-js API server, which also serves as a web-socket server, and I send the name of the table that was changed to the client over a channel.
So, depending on which table has been modified, my react-js client re-fetches the updated information.
The client has connection to the web-socket as appears on the network tab of the developer tools for browsers.