'How to change the `frontend_domain` port in `GRAPHQL_AUTH` in the verification mail?

I'm working on a Docker-Django-Graphene-React stack where Django is the backend which receive GraphQL queries through Graphene from React which acts as the frontend. Everything runs in docker containers. Django on port 8000 and React on 3000.

I'm currently working on the authentication with the python's django-graqhql-auth package.

When a user register itself on the frontend form, the register mutation is correctly made to the backend and the account is created.

A mail is sent at the same time to the user's registered mail address containing a verification link with a token that must be used with the veryifyToken mutation in order to flag the account as verified.

Here is an example of the link: http://localhost:8000/activate/eyJ1c2VybmFtZSI6IkpvaG5zb2ZuZiIsImFjdGlvbiI6ImFjdGl2YXRpb24ifQ:1mQr0R:Wh25LJ6A1PRVCQT730kXXIk4i2QJgz1a4aNDe7RoZM0

The problem is that the port on the link is 8000, which redirects to the backend (Django). I would like to redirect the user on port 3000 which is the frontend (React).

According to the documentation, I should be able to change the frontend_domain which I did. I also changed the path and the protocol values to see if it works:

Here is what I put in my backend's settings.py file:

GRAPHQL_AUTH = {
    "EMAIL_TEMPLATE_VARIABLES": {
        "protocol": "https",
        "frontend_domain": "localhost:3000",
        "path": "verify",
    }
}

And I end up with this link:

https://localhost:8000/verify/eyJ1c2VybmFtZSI6IkpvaG5zZmdvZmdzbmRmIiwiYWN0aW9uIjoiYWN0aXZhdGlvbiJ9:1mQrIr:2o818drqPP8oVTE4E6fg2F6vMu2zITOjkF96z5K1whY

The protocol and path variables were correctly changed but not the frontend_domain. The problem is that I cannot redirect the user directly to the frontend.

Is there a way to fix this? Or do I have to create a route on the backend which will redirect the user to the frontend with the token so that I can use the verifyToken mutation?



Solution 1:[1]

I might be answering this late, but replace frontend_domain with domain and it will work.

Solution 2:[2]

you just have to update to latest version.

pip install --upgrade django-graphql-auth

Solution 3:[3]

I noticed that you used in protocol: "https" , but should probably be protocol: "http".

I'm in the same project using Django and Graphql Auth and for me worked to send the email to the frontend to Next.js by using protocol: "http".

GRAPHQL_AUTH = {
        "EMAIL_TEMPLATE_VARIABLES": {
        "protocol": "http",
        "frontend_domain": "localhost:3000",
        "path": "verify",
      } 
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 abhay babbar
Solution 2 myshy93
Solution 3 General Grievance