0

I have a url with paramenters in my react routes. App Routes

I can access the route via {Link} from react router dom as shown below. The page loads upon button click. enter image description here

However when I refresh the page or try to access the URL via the address bar, I get a blank page and this error message enter image description here

It works fine locally but the blank page comes up in production. I am hosting the website on heroku.

3
  • The error logs are not due to react router. Problem is the way you are serving the static files. You need to fix that first. The below link might be useful, stackoverflow.com/questions/56981150/… Commented Jul 23, 2021 at 17:59
  • @Drew Reese. All other pages are loading except this particular details page. I dunno if that means the routing works or not Commented Jul 23, 2021 at 18:39
  • Ah, I see, I didn't "enbiggen" your screencaps. Yeah, seems to be an issue with how the static assets are handled. Check the link in the other comment. Also, check what all the errors link to or reference. Can you update your question to include that BeatDetailPage? Commented Jul 23, 2021 at 18:46

2 Answers 2

1

The best way to handle it is to add a base tag in your index.html.

<base href="/" />
Sign up to request clarification or add additional context in comments.

Comments

0

I fixed the problem using the solution in the link below. I initially set my homepage to "." in my package.json and eventually changed it to my app domain

https://stackoverflow.com/a/66950806/6542175

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.