I’m working on a web app for my final year project. The frontend is in React and the backend uses Django with SQLite. Everything should be working, but I’m having trouble getting the frontend to talk to the backend.
The homepage loads fine, but I can’t get to any other pages. When I try to sign in or sign up, it just goes back to the homepage. I’ve checked CORS settings, made sure the URLs are correct, and tried running production builds. But nothing seems to work.
I’ve put the build folder from the frontend into the backend directory. When I start both servers, they run without errors. The backend pages work fine on their own. But the frontend just won’t connect properly.
Here’s what my Django settings look like:
INSTALLED_APPS = [
# ... standard Django apps ...
'rest_framework_simplejwt',
'api',
'rest_framework',
'djoser',
'corsheaders',
'backend',
'rest_framework_simplejwt.token_blacklist',
]
CORS_ALLOWED_ORIGINS = [
'http://localhost:3000',
'http://127.0.0.1:8000',
# ... other origins ...
]
# ... database and static file settings ...
And my urls.py:
urlpatterns = [
path('admin/', admin.site.urls),
path('auth/', include('djoser.urls')),
path('auth/', include('djoser.urls.jwt')),
path('news/', views.NewsView.as_view()),
# ... other paths ...
]
# ... static and catch-all URL patterns ...
Any ideas on what could be causing this? I’m really stuck and running out of time to submit my project.