1

I am building a portfolio page, and used Create-react-app as well as a node server to handle API calls.

Everything was working great in dev, and I went to deploy the application. This is my first full deployment, and it was... interesting. I solved most problems, but I'm having issues solving this last one, which is related to the blog on my site. The blog routing is set up like this: <Route path="/blogposts/:slug" component={BlogPost}/> Well, the only blog I have atm, which should be served at /blogposts/how-i-built-this-site, returns a blank page, my index.html file.

Instead of pasting in some code, the easiest solution is probably linking the github, since this is a fairly large project (for me).

If any more info is needed, please let me know. If anyone figures this out, they're my hero!

dsmith1515
  • 77
  • 1
  • 9
  • it works great in dev but not prod? which web server are you using? – C.Gochev Jan 18 '20 at 06:42
  • Heroku, Heroku Local Web. With Nodemon, it was working fine, rendering the blog. – dsmith1515 Jan 18 '20 at 06:58
  • 1
    https://stackoverflow.com/questions/41772411/react-routing-works-in-local-machine-but-not-heroku – C.Gochev Jan 18 '20 at 07:20
  • Thanks, this info is very helpful. I think I should be more specific however, about my problem - the routing worked fine when I was using a proxy in dev. Now that my index.html is being served by an express server, all my API calls work fine, but the route with variable params will not render, it is not being routed properly. – dsmith1515 Jan 18 '20 at 07:56

2 Answers2

2

I think you need to wrap your Routes with Switch component.

<Switch>
   <Route ....>
</Switch>
Zunaib Imtiaz
  • 2,849
  • 11
  • 20
  • Thank you for the suggestion, I tried wrapping the routes with the Switch component, and it did not solve the issue. This one really has me scratching my head! – dsmith1515 Jan 18 '20 at 06:37
0

This was solved by adding in the index.html file.

Still don't know why this issue occurred, it may have something to do with Othka. Either way, it is fixed now, which is a win for me.

dsmith1515
  • 77
  • 1
  • 9