Reputation: 45
My project has django-rest framework backend api server and reactjs frontend.
there is index.html of reactjs file in django static/file directory. So, I can access the react page by the url "backend_url.com/static/index.html".
problem is I want to access the url of react router. "backend_url.com/static/index.html/public/log-in-page/" like this. to go directly to react log-in page.
but, the server try to find "static/index.html/public/log-in-page/" directory. so It will fail.
Finally, what I want to develop is to go directly the specific react page and pass over parameters by the url.
how can I reach that?
Upvotes: 0
Views: 566
Reputation: 2706
You will have to configure your webserver so that it serves index.html
regardless of the rest of the URL. Depending on your webserver, this will done one way or another.
However, if you are using Django, I suggest that you use Django views to render your page. You could be saving your React page as a template, and render the template from the view.
# urls.py
from django.urls import re_path
url_patterns = [
re_path(r'^/your/app/?.*', views.app)
]
# views.py
from django.shortcuts import render
def app(request):
return render(request, 'index.html')
Upvotes: 1