fix: update CORS handling for public chatflow requests#5706
Conversation
Summary of ChangesHello @prd-hoang-doan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a security inconsistency by expanding Cross-Origin Resource Sharing (CORS) validation to encompass all public chatflow endpoints, not just the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request effectively addresses the issue of expanding CORS validation to include all public chatflow endpoints, not just the /prediction/ endpoint. The introduction of the ALLOWED_SLUGS constant centralizes the list of public endpoints, improving maintainability. The refactoring of extractChatflowId and the new isPublicChatflowRequest function correctly implement the broader validation logic. The existing comment regarding code simplification in isPublicChatflowRequest is valid and has been retained as it does not conflict with the provided rules. Overall, this is a good improvement for the security posture and consistency of the application.
9c20bed to
8edc40d
Compare
Fix: Expand CORS validation for public chatflow APIs used for embedded chatbot
Summary
This PR extends CORS domain validation to cover all public chatflow endpoints, not just the
/prediction/endpoint. Previously, only prediction requests were validated against per-chatflow allowed origins, leaving other public APIs (/public-chatbotConfig/ and /chatflows-streaming/) without proper origin validation.Issue: #5691
Problem:
The existing CORS validation only checked domain restrictions for /prediction/ endpoints. Other public chatflow APIs that should have the same security controls were not being validated, creating an inconsistent security posture.
Testing:
Current:
Screen.Recording.2026-02-04.at.22.25.21.mov
After fixing:
Screen.Recording.2026-02-04.at.22.27.21.mov