Deploy client to Heroku when using React Router

Hi,

I had some issues deploying the client to Heroku. I eventually got it working by adding a react build pack but I am curious as to why you didn’t have to do this?

I have looked around online but can’t find anything conclusive.

Thanks,
Chris

Hi @ChrisBagge!

Hmm did you use the Heroku web UI to deploy, or did you use the Heroku CLI and added the buildpack through the CLI as well?

I seem to remember an earlier version of the course having to add the buildpack but before I dig into that, let me know how you deployed it!

Also congrats on finishing the course! :slight_smile:

Hi,

Thanks for getting back to me.

My implementation is slightly different I created a react app from scratch with create-react-app using the typescript template and I ended up using react-router instead of reach not sure if this is ultimately what caused the deployment to fail.

Anyway, to solve this without using a buildpack I had to add a static.json file to the root of the app with the following content

{

“root”: “build/”,

“routes”: {

"/**": "index.html"

}

}
I used the web UI to install,

I really enjoyed the tutorial and I am looking forward to the next one
Chris

1 Like