I'm using dj-rest-auth with react and i'm trying to use the frontend url instead of the backend url. The solution i am using for the account creation confirmation email affects the reset password email too but only partially. It does not effect the port. It only tries to add a key to the reset link where there is none and throws me an error.
So i was wondering if there is a way to change the url from port 8000 to port 3000. This is what i have tried:
class AccountAdapter(DefaultAccountAdapter):
def is_open_for_signup(self, request: HttpRequest):
return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True)
def send_mail(self, template_prefix, email, context):
if settings.DEBUG:
context["activate_url"] = (
"http://localhost:3000/accounts/confirm-email/" + context["key"]
)
else:
context["activate_url"] = (
settings.FRONTEND_URL + "/accounts/confirm-email/" + context["key"]
)
return super().send_mail(template_prefix, email, context)
If i get rid of the key part it doesn't give me an error but keeps port 8000 and breaks my account confirmation emails. If i don't get rid of the key it gives me:
django | "http://localhost:3000/accounts/confirm-email/" + context["key"]
django | KeyError: 'key'