What does the CORS env variables do? #8458
Replies: 5 comments 1 reply
-
The CORS environment variables in Dify are used to set cross-origin access policies. Specifically:
If you set these variables to your own domain, it will restrict access to only your specified domain, thereby preventing others from embedding your chatbot. For example: CONSOLE_CORS_ALLOW_ORIGINS=my-frontend-domain
WEB_API_CORS_ALLOW_ORIGINS=my-frontend-domain This configuration ensures that only requests from |
Beta Was this translation helpful? Give feedback.
-
I already set them to my own domain. |
Beta Was this translation helpful? Give feedback.
-
To ensure that your chatbot only works on your domain, you need to set additional environment variables beyond
export CONSOLE_API_URL="https://riverhill.ai/api/console"
export CONSOLE_WEB_URL="https://riverhill.ai/console"
export SERVICE_API_URL="https://riverhill.ai/api/service"
export APP_API_URL="https://riverhill.ai/api/app"
export APP_WEB_URL="https://riverhill.ai/app"
export WEB_API_CORS_ALLOW_ORIGINS="https://riverhill.ai"
export CONSOLE_CORS_ALLOW_ORIGINS="https://riverhill.ai"
export const isMyDomain = () => {
return document.referrer.includes('riverhill.ai')
} By setting these environment variables and adding a referrer check in your code, you can ensure that your chatbot only works on your specified domain [1][2]. |
Beta Was this translation helpful? Give feedback.
-
How to configure the CORS? Currently: I want to prevent others from embedding my chatbot. |
Beta Was this translation helpful? Give feedback.
-
Do I have to add "" arround the url? |
Beta Was this translation helpful? Give feedback.
-
Self Checks
Provide a description of requested docs changes
If set these variables to my own domain, does it prevent others from embedding my chatbot?
The iframe already exposes the url, people can just copy the iframe code and embed my chatbot.
CONSOLE_CORS_ALLOW_ORIGINS=my-frontend-domain
WEB_API_CORS_ALLOW_ORIGINS=my-frontend-domain
Beta Was this translation helpful? Give feedback.
All reactions