Issue with Incorrect Invitation Link: Uses Localhost Instead of Configured URL Prefix #1148

Closed
opened 2026-02-21 17:30:13 -05:00 by yindo · 4 comments
Owner

Originally created by @mwnu on GitHub (Mar 2, 2024).

Originally assigned to: @crazywoola on GitHub.

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.5.7

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Despite entering URL prefixes such as CONSOLE_WEB_URL in the settings, the invitation link received by the invitee's email when inviting others from the web interface still appears as "http://127.0.0.1:3000/activate?token=xxx".

✔️ Expected Behavior

CONSOLE_WEB_URL+/activate?token=xxx,like:http://cloud.dify.ai/activate?token=xxx

Actual Behavior

image

http://127.0.0.1:3000/activate?token=xxx

Originally created by @mwnu on GitHub (Mar 2, 2024). Originally assigned to: @crazywoola on GitHub. ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Dify version 0.5.7 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Despite entering URL prefixes such as CONSOLE_WEB_URL in the settings, the invitation link received by the invitee's email when inviting others from the web interface still appears as "http://127.0.0.1:3000/activate?token=xxx". ### ✔️ Expected Behavior CONSOLE_WEB_URL+/activate?token=xxx,like:http://cloud.dify.ai/activate?token=xxx ### ❌ Actual Behavior ![image](https://github.com/langgenius/dify/assets/45463732/d9c2924b-e3eb-4cfd-aac8-2961f3fb3461) http://127.0.0.1:3000/activate?token=xxx
yindo added the 🐞 bug label 2026-02-21 17:30:13 -05:00
yindo closed this issue 2026-02-21 17:30:13 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 2, 2024):

Based on the information you've provided, it seems like the CONSOLE_WEB_URL setting is not being correctly utilized when generating the invitation link. This setting should be used as the base URL for the activation link, instead of the hardcoded http://127.0.0.1:3000.

The invitation email is prepared and sent in the send_invite_member_mail_task function within the api/tasks/mail_invite_member_task.py file. This function generates the email content based on the provided language (either English or Chinese), using the render_template method to fill in the email template with the recipient's information, inviter's name, workspace name, and a URL with an activation token.

Here's a general approach to resolve this issue:

  1. Ensure that the CONSOLE_WEB_URL setting is correctly configured in your environment or configuration files. This setting should point to http://cloud.dify.ai or the appropriate base URL for your production environment.

  2. In the send_invite_member_mail_task function, replace the hardcoded http://127.0.0.1:3000 part with the value of CONSOLE_WEB_URL. The token part of the URL (activate?token=xxx) should be appended to this base URL.

  3. The resulting URL should then be passed to the render_template method as the {{ url }} variable.

Here is a hypothetical example in Python, assuming you are using an environment variable for CONSOLE_WEB_URL:

import os

# Assuming you fetch the token value from somewhere
token = "xxx"
base_url = os.getenv("CONSOLE_WEB_URL", "http://127.0.0.1:3000")  # Fallback to localhost if not set
activation_link = f"{base_url}/activate?token={token}"

# Now, pass the activation_link to the template rendering context
context = {
    "url": activation_link,
    # other context variables...
}

Please replace the Python example with the appropriate code according to your application's language and framework. The key is to dynamically construct the URL using the CONSOLE_WEB_URL setting and ensure it is correctly passed to the email template.

For more details, you can refer to the source code in the api/tasks/mail_invite_member_task.py file and the api/templates/invite_member_mail_template_en-US.html file.

Please let me know if this helps or if you need further assistance.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot[bot] commented on GitHub (Mar 2, 2024): <!-- Answer --> Based on the information you've provided, it seems like the `CONSOLE_WEB_URL` setting is not being correctly utilized when generating the invitation link. This setting should be used as the base URL for the activation link, instead of the hardcoded `http://127.0.0.1:3000`. The invitation email is prepared and sent in the `send_invite_member_mail_task` function within the `api/tasks/mail_invite_member_task.py` file. This function generates the email content based on the provided language (either English or Chinese), using the `render_template` method to fill in the email template with the recipient's information, inviter's name, workspace name, and a URL with an activation token. Here's a general approach to resolve this issue: 1. Ensure that the `CONSOLE_WEB_URL` setting is correctly configured in your environment or configuration files. This setting should point to `http://cloud.dify.ai` or the appropriate base URL for your production environment. 2. In the `send_invite_member_mail_task` function, replace the hardcoded `http://127.0.0.1:3000` part with the value of `CONSOLE_WEB_URL`. The token part of the URL (`activate?token=xxx`) should be appended to this base URL. 3. The resulting URL should then be passed to the `render_template` method as the `{{ url }}` variable. Here is a hypothetical example in Python, assuming you are using an environment variable for `CONSOLE_WEB_URL`: ```python import os # Assuming you fetch the token value from somewhere token = "xxx" base_url = os.getenv("CONSOLE_WEB_URL", "http://127.0.0.1:3000") # Fallback to localhost if not set activation_link = f"{base_url}/activate?token={token}" # Now, pass the activation_link to the template rendering context context = { "url": activation_link, # other context variables... } ``` Please replace the Python example with the appropriate code according to your application's language and framework. The key is to dynamically construct the URL using the `CONSOLE_WEB_URL` setting and ensure it is correctly passed to the email template. For more details, you can refer to the source code in the [api/tasks/mail_invite_member_task.py](https://github.com/langgenius/dify/blob/main/api/tasks/mail_invite_member_task.py) file and the [api/templates/invite_member_mail_template_en-US.html](https://github.com/langgenius/dify/blob/main/api/templates/invite_member_mail_template_en-US.html) file. Please let me know if this helps or if you need further assistance. ## Sources - [api/templates/invite_member_mail_template_en-US.html](https://github.com/langgenius/dify/blob/main/api/templates/invite_member_mail_template_en-US.html) - [api/tasks/mail_invite_member_task.py](https://github.com/langgenius/dify/blob/main/api/tasks/mail_invite_member_task.py) <!-- Dosu Comment Footer --> <details open> <summary> #### About Dosu </summary> This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. </details>
Author
Owner

@crazywoola commented on GitHub (Mar 2, 2024):

Where did you set this environment variable?
Because the service that sends the email needs to use worker.
So you should set this under api and worker in you env configuration . (docker-compose or .env file)

@crazywoola commented on GitHub (Mar 2, 2024): Where did you set this environment variable? Because the service that sends the email needs to use `worker`. So you should set this under `api` and `worker` in you env configuration . (docker-compose or .env file)
Author
Owner

@mwnu commented on GitHub (Mar 2, 2024):

Where did you set this environment variable? Because the service that sends the email needs to use worker. So you should set this under api and worker in you env configuration . (docker-compose or .env file)

I modified the docker-compose according to the template found at https://github.com/langgenius/dify/blob/main/docker/docker-compose.yaml. The template's worker service did not indicate the need for CONSOLE_API_URL. After adding it, the invitation link correctly displayed the domain prefix.

@mwnu commented on GitHub (Mar 2, 2024): > Where did you set this environment variable? Because the service that sends the email needs to use `worker`. So you should set this under `api` and `worker` in you env configuration . (docker-compose or .env file) I modified the docker-compose according to the template found at https://github.com/langgenius/dify/blob/main/docker/docker-compose.yaml. The template's worker service did not indicate the need for CONSOLE_API_URL. After adding it, the invitation link correctly displayed the domain prefix.
Author
Owner

@gijigae commented on GitHub (Mar 17, 2024):

For those who come to this issue because of the incorrect invitation link, you need to add CONSOLE_WEB_URL to the worker in the docker-compose.yaml. See the mail_invite_member_task.py file for the reference.

https://github.com/langgenius/dify/blob/a8e694c235758ddbc82fa426d5ed7cab4e160aa4/api/tasks/mail_invite_member_task.py#L32

@gijigae commented on GitHub (Mar 17, 2024): For those who come to this issue because of the incorrect invitation link, you need to add `CONSOLE_WEB_URL` to the `worker` in the docker-compose.yaml. See the `mail_invite_member_task.py` file for the reference. https://github.com/langgenius/dify/blob/a8e694c235758ddbc82fa426d5ed7cab4e160aa4/api/tasks/mail_invite_member_task.py#L32
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#1148