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 seemed fine when the developer handed it over, but now I’m having trouble getting the frontend to talk to the backend.
The homepage loads okay, but that’s it. Clicking links just refreshes the homepage. Login always fails and signup just goes back to the homepage too.
I’ve tried a bunch of things:
- Checked CORS settings
- Made production builds
- Double-checked urls.py
My process:
- npm run build for frontend
- Copy the build folder to the backend root
- Run npm start for frontend and py manage.py runserver for backend
Both run without errors, but only the homepage works on the frontend. The backend admin page and other Django pages work fine on their own.
I’m really stuck and my deadline is in 2 days. Any ideas what could be wrong? I’ve exhausted all my options even with ChatGPT’s help.
Here’s a snippet from my Django settings:
INSTALLED_APPS = [
'django.contrib.admin',
'rest_framework',
'corsheaders',
'api',
# other apps...
]
CORS_ALLOWED_ORIGINS = [
'http://localhost:3000',
'http://127.0.0.1:8000',
# other origins...
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
Any help would be really appreciated!