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:
- Adding
"homepage": "https://www.example.com/"to mypackage.json. - Adding
<base href="/" />toindex.html - Adding
"homepage": "."topackage.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.
index.htmlfile built by react directly, but this is a temp fix. I was parsing out the info fromindex.htmland serving my react app on another html file - really not sure why there would be a difference. And thanks for the links.