The newly created chat assistant reports an error when embedded in the website #12114

Closed
opened 2026-02-21 19:05:50 -05:00 by yindo · 8 comments
Owner

Originally created by @wh-zxt-01 on GitHub (Mar 25, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • 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).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When publishing, choose to embed the website,
Iframe tag method
`` According to the document, copy the iframe code into the tags on your website used to display AI applications, such as

< Section>and other labels.

Image
report errors:
{
"message": "无权访问",
"status": 401,
"timestamp": "2025-03-25T17:44:53+0800",
"costMillis": 0
}
Directly copying the src address of the iframe request still yields an error

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @wh-zxt-01 on GitHub (Mar 25, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When publishing, choose to embed the website, Iframe tag method `<iframe src="http://192.168.90.182/chatbot/y4QxBhpqwj7Bu8oR" style="width: 100%; height: 100%; min-height: 700px" frameborder="0" allow="microphone"> </iframe>` According to the document, copy the iframe code into the tags on your website used to display AI applications, such as<div>< Section>and other labels. ![Image](https://github.com/user-attachments/assets/45d0721f-fe97-49da-8e20-c0c2e7ceefd3) report errors: { "message": "无权访问", "status": 401, "timestamp": "2025-03-25T17:44:53+0800", "costMillis": 0 } Directly copying the src address of the iframe request still yields an error ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug🤔 cant-reproduce labels 2026-02-21 19:05:50 -05:00
yindo closed this issue 2026-02-21 19:05:51 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2025):

The "无权访问" (Unauthorized access) error with status 401 is likely due to the difyChatbotConfig being missing or the token not being provided in the configuration. Ensure that the difyChatbotConfig is correctly defined in your HTML file before the script is included, and that it contains a valid token. The token is necessary for authorization and can be found in the chatbot settings page.

Additionally, when embedding a Dify chatbot in a webpage using an iframe, make sure to use HTTPS instead of HTTP in the iframe src URL to avoid potential security issues. For example:

<iframe
  src="https://domain/chatbot/id"
  style="width: 100%; height: 700px; border: none;"
  allow="microphone"
/>

Using HTTPS is crucial for the iframe to load properly [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 25, 2025): <!-- Answer --> The "无权访问" (Unauthorized access) error with status 401 is likely due to the `difyChatbotConfig` being missing or the token not being provided in the configuration. Ensure that the `difyChatbotConfig` is correctly defined in your HTML file before the script is included, and that it contains a valid token. The token is necessary for authorization and can be found in the chatbot settings page. Additionally, when embedding a Dify chatbot in a webpage using an iframe, make sure to use HTTPS instead of HTTP in the iframe `src` URL to avoid potential security issues. For example: ```html <iframe src="https://domain/chatbot/id" style="width: 100%; height: 700px; border: none;" allow="microphone" /> ``` Using HTTPS is crucial for the iframe to load properly <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/public/embed.js)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/13501)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=other)</sup>
Author
Owner

@wh-zxt-01 commented on GitHub (Mar 25, 2025):

The "无权访问" (Unauthorized access) error with status 401 is likely due to the difyChatbotConfig being missing or the token not being provided in the configuration. Ensure that the difyChatbotConfig is correctly defined in your HTML file before the script is included, and that it contains a valid token. The token is necessary for authorization and can be found in the chatbot settings page.

Additionally, when embedding a Dify chatbot in a webpage using an iframe, make sure to use HTTPS instead of HTTP in the iframe src URL to avoid potential security issues. For example:

@wh-zxt-01 commented on GitHub (Mar 25, 2025): > The "无权访问" (Unauthorized access) error with status 401 is likely due to the `difyChatbotConfig` being missing or the token not being provided in the configuration. Ensure that the `difyChatbotConfig` is correctly defined in your HTML file before the script is included, and that it contains a valid token. The token is necessary for authorization and can be found in the chatbot settings page. > > Additionally, when embedding a Dify chatbot in a webpage using an iframe, make sure to use HTTPS instead of HTTP in the iframe `src` URL to avoid potential security issues. For example: > > <iframe > src="https://domain/chatbot/id" > style="width: 100%; height: 700px; border: none;" > allow="microphone" > /> > Using HTTPS is crucial for the iframe to load properly [[1]](https://github.com/langgenius/dify/blob/main/web/public/embed.js)[[2]](https://github.com/langgenius/dify/issues/13501). > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu)._ > > Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6c7d5088-431b-4cf4-835c-c6df93114185?feedback_type=other) >It was copied directly on the page, does this token have to be obtained by oneself? @crazywoola ![Image](https://github.com/user-attachments/assets/37271773-cfb6-47a3-9d94-b09c899785d4)
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2025):

Yes, the token for the difyChatbotConfig needs to be obtained manually when embedding a chatbot using an iframe. The token is required for authorization and is automatically generated by Dify. You can find the token in the chatbot settings page, and it should be included in the difyChatbotConfig in your HTML file before the script is included [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 25, 2025): <!-- Answer --> Yes, the token for the `difyChatbotConfig` needs to be obtained manually when embedding a chatbot using an iframe. The token is required for authorization and is automatically generated by Dify. You can find the token in the chatbot settings page, and it should be included in the `difyChatbotConfig` in your HTML file before the script is included <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/public/embed.js)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/62aa3673-276a-430d-ab57-3ac72d422ef7?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/62aa3673-276a-430d-ab57-3ac72d422ef7?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/62aa3673-276a-430d-ab57-3ac72d422ef7?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/62aa3673-276a-430d-ab57-3ac72d422ef7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/62aa3673-276a-430d-ab57-3ac72d422ef7?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/62aa3673-276a-430d-ab57-3ac72d422ef7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/62aa3673-276a-430d-ab57-3ac72d422ef7?feedback_type=other)</sup>
Author
Owner

@wh-zxt-01 commented on GitHub (Mar 25, 2025):

The chatbot interface did not find the token, clicking on this to start still yields 401,Can you take a screenshot of the picture
Image @dosu

@wh-zxt-01 commented on GitHub (Mar 25, 2025): The chatbot interface did not find the token, clicking on this to start still yields 401,Can you take a screenshot of the picture ![Image](https://github.com/user-attachments/assets/b7427245-86e3-449d-ac2d-b75521af89b6) @dosu
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2025):

To resolve the 401 error when the chatbot interface does not find the token, ensure that the difyChatbotConfig is correctly defined in your HTML file before the embed.js script is included. The configuration must include a valid token for the chatbot, which can be found on the chatbot settings page. Here is a sample configuration:

<script>
  window.difyChatbotConfig = {
    token: "your-chatbot-token", // Replace with your actual token
    // other configuration options
  };
</script>
<script src="path/to/embed.js"></script>

Make sure that the token is correctly set and that the script is placed after the <body> element to ensure it functions properly. If the token is missing or incorrect, the script will log an error: difyChatbotConfig is empty or token is not provided [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 25, 2025): <!-- Answer --> To resolve the 401 error when the chatbot interface does not find the token, ensure that the `difyChatbotConfig` is correctly defined in your HTML file before the `embed.js` script is included. The configuration must include a valid `token` for the chatbot, which can be found on the chatbot settings page. Here is a sample configuration: ```html <script> window.difyChatbotConfig = { token: "your-chatbot-token", // Replace with your actual token // other configuration options }; </script> <script src="path/to/embed.js"></script> ``` Make sure that the `token` is correctly set and that the script is placed after the `<body>` element to ensure it functions properly. If the token is missing or incorrect, the script will log an error: `difyChatbotConfig is empty or token is not provided` <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/public/embed.js)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/0cd2ad7b-36ef-4d81-9f8a-2981d8fd3512?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/0cd2ad7b-36ef-4d81-9f8a-2981d8fd3512?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/0cd2ad7b-36ef-4d81-9f8a-2981d8fd3512?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/0cd2ad7b-36ef-4d81-9f8a-2981d8fd3512?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0cd2ad7b-36ef-4d81-9f8a-2981d8fd3512?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/0cd2ad7b-36ef-4d81-9f8a-2981d8fd3512?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0cd2ad7b-36ef-4d81-9f8a-2981d8fd3512?feedback_type=other)</sup>
Author
Owner

@wh-zxt-01 commented on GitHub (Mar 25, 2025):

I know this configuration. What I mean is how to obtain the token ,Is it the URL below the image, the string after the parameter chat 。@dosu

Image

@wh-zxt-01 commented on GitHub (Mar 25, 2025): I know this configuration. What I mean is how to obtain the token ,Is it the URL below the image, the string after the parameter chat 。@dosu ![Image](https://github.com/user-attachments/assets/e0671d95-8f1e-4b0e-bf1e-b9d024ac48ca)
Author
Owner

@crazywoola commented on GitHub (Mar 25, 2025):

{
  "message": "无权访问",
  "status": 401,
  "timestamp": "2025-03-25T17:44:53+0800",
  "costMillis": 0
}

I don't think this is return by the dify itself.

  • First, we do not return errors with Chinese.
  • We do not have columns like costMillis in our system.
@crazywoola commented on GitHub (Mar 25, 2025): ``` { "message": "无权访问", "status": 401, "timestamp": "2025-03-25T17:44:53+0800", "costMillis": 0 } ``` I don't think this is return by the dify itself. - First, we do not return errors with Chinese. - We do not have columns like `costMillis` in our system.
Author
Owner

@wh-zxt-01 commented on GitHub (Mar 26, 2025):

But real-time is the public access URL copied from the image above @crazywoola

@wh-zxt-01 commented on GitHub (Mar 26, 2025): But real-time is the public access URL copied from the image above @crazywoola
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12114