Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: allow unauthenticated CORS preflight for embedded bots (#30587)
CodeCraftsman89463cc11d7f
diff --git a/api/extensions/ext_blueprints.py b/api/extensions/ext_blueprints.pyindex cf994c11dfc..7d13f0c061a 100644--- a/api/extensions/ext_blueprints.py+++ b/api/extensions/ext_blueprints.py@@ -6,6 +6,7 @@ BASE_CORS_HEADERS: tuple[str, ...] = ("Content-Type", HEADER_NAME_APP_CODE, HEADSERVICE_API_HEADERS: tuple[str, ...] = (*BASE_CORS_HEADERS, "Authorization")AUTHENTICATED_HEADERS: tuple[str, ...] = (*SERVICE_API_HEADERS, HEADER_NAME_CSRF_TOKEN)FILES_HEADERS: tuple[str, ...] = (*BASE_CORS_HEADERS, HEADER_NAME_CSRF_TOKEN)+EMBED_HEADERS: tuple[str, ...] = ("Content-Type", HEADER_NAME_APP_CODE)EXPOSED_HEADERS: tuple[str, ...] = ("X-Version", "X-Env", "X-Trace-Id")@@ -42,10 +43,28 @@ def init_app(app: DifyApp):_apply_cors_once(web_bp,- resources={r"/*": {"origins": dify_config.WEB_API_CORS_ALLOW_ORIGINS}},- supports_credentials=True,- allow_headers=list(AUTHENTICATED_HEADERS),- methods=["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],+ resources={+ # Embedded bot endpoints (unauthenticated, cross-origin safe)+ r"^/chat-messages$": {+ "origins": dify_config.WEB_API_CORS_ALLOW_ORIGINS,+ "supports_credentials": False,+ "allow_headers": list(EMBED_HEADERS),+ "methods": ["GET", "POST", "OPTIONS"],+ },+ r"^/chat-messages/.*": {+ "origins": dify_config.WEB_API_CORS_ALLOW_ORIGINS,+ "supports_credentials": False,+ "allow_headers": list(EMBED_HEADERS),+ "methods": ["GET", "POST", "OPTIONS"],+ },+ # Default web application endpoints (authenticated)+ r"/*": {+ "origins": dify_config.WEB_API_CORS_ALLOW_ORIGINS,+ "supports_credentials": True,+ "allow_headers": list(AUTHENTICATED_HEADERS),+ "methods": ["GET", "PUT", "POST", "DELETE", "OPTIONS", "PATCH"],+ },+ },expose_headers=list(EXPOSED_HEADERS),)app.register_blueprint(web_bp)