10/11/2024
As a Software developer working with Django REST Framework and Djoser, I’ve often noticed a common issue among fellow developers: getting email activation links to correctly redirect users to the frontend. By default, Djoser sends an activation link with the backend URL (something like http://localhost:8000/activation/?uid=...&token=...). This is fine if you’re only working with a backend interface, but when there’s a React or Vue frontend involved, this setup falls short.
The problem is simple yet frustrating. A user signs up, receives an activation email, clicks the link—only to be taken to the backend server (which is not where they need to be)! Ideally, that link should lead to http://localhost:3000/activation/... for a React frontend or http://localhost:8080/... for a Vue frontend, where users can complete activation in a polished, user-friendly interface.
I've seen countless questions about this in forums, and though there are a few workarounds out there, I haven’t come across a complete guide that walks through how to set up email activation and password reset in a way that integrates smoothly with both Django and a separate frontend. After solving this issue myself, I decided it was time to share a straightforward guide to help others avoid the same headache and get their APIs production-ready with best practices.
https://medium.com//building-a-production-ready-django-rest-api-with-djoser-email-activation-password-reset-best-3adbe7f096af