0

I am building an app with django3.2 and React 17 using react-router-dom 6.

My react app is served at https://www.example.com/

And if I navigate within the app to https://www.example.com/auth/signup I get the form, however, if I input the url directly into the browser I am taken to a blank page.

In my django.urls, I have a catch all that should send the path down to my react app, and in local development it works great.

urlpatterns = [
    ...,
    re_path(r'^(?:.*)/?$', homepage),
]

PROBLEM: In production I am taken to a blank page.

I suspect it has to do with relative paths in production. I've followed these questions:

Django static file serving in conflict with React Router

React router not loading dynamic url in production

And so far have tried:

  1. Adding "homepage": "https://www.example.com/" to my package.json.
  2. Adding <base href="/" /> to index.html
  3. Adding "homepage": "." to package.json

But so far nothing has worked, and I need this feature, particularly for email verification. Happy to clarify anything or share front end code.

2
  • What sort of server environment is hosting/serving your app? Does anything in the create-react-app deployment docs help? Commented Jun 30, 2022 at 19:56
  • I'm on python anywhere. I fixed it by serving the index.html file built by react directly, but this is a temp fix. I was parsing out the info from index.html and serving my react app on another html file - really not sure why there would be a difference. And thanks for the links. Commented Jun 30, 2022 at 20:30

0

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.