dify icon indicating copy to clipboard operation
dify copied to clipboard

After configuring the routing and static resource prefixes, some resource references on the packaged page have the prefix, but some do not.

Open Vulgarever opened this issue 8 months ago • 1 comments

Self Checks

  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Next.js configuration file

Image

The resource references of the page after packaging

Image

✔️ Expected Behavior

The resource introductions on the page after packaging should all be prefixed according to the configuration.

❌ Actual Behavior

No response

Vulgarever avatar Apr 10 '25 08:04 Vulgarever

In a Next.js application, some resources might not receive the prefix due to specific conditions related to environment variables and document attributes. Here are some potential reasons why this might happen:

  1. Environment Variables Not Set: Ensure that the environment variables NEXT_PUBLIC_API_PREFIX and NEXT_PUBLIC_PUBLIC_API_PREFIX are correctly set. If these are not set, the application will attempt to retrieve the prefixes from the document's body attributes. If these attributes (data-api-prefix and data-pubic-api-prefix) are also not present, default values are used instead.

  2. Document Attributes Not Present: If the document's body does not have the attributes data-api-prefix and data-pubic-api-prefix, and the environment variables are not set, the application defaults to using hardcoded URLs like http://localhost:5001/console/api and http://localhost:5001/api.

  3. Marketplace Prefixes: Similarly, if NEXT_PUBLIC_MARKETPLACE_API_PREFIX and NEXT_PUBLIC_MARKETPLACE_URL_PREFIX are not set, and the document's body does not have the attributes data-marketplace-api-prefix and data-marketplace-url-prefix, the marketplace prefixes will be empty strings [1].

To resolve the issue, verify that all necessary environment variables are set correctly in your .env.local file and that the document attributes are present if needed. Additionally, ensure that the basePath and assetPrefix settings in your Next.js configuration file are correctly configured to match your deployment environment.

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] avatar Apr 10 '25 08:04 dosubot[bot]