On the development server, you just set up a route for everything that doesn't start with api/or static/to return the main file app.html. Example
class AppHTMLView(View):
def get(self, request):
fn = os.path.join(settings.BASE_DIR, "app", "app.html")
with open(fn, 'r') as fh:
return HttpResponse(fh.read())
And on your production server, you configure Nginx accordingly. Something like that
...
location / {
root /var/www/example.com/static_files/;
try_files '' /app.html =404;
}
But this is in no way characteristic of React, but is common to all single-page applications.
source
share