[PR #30587] fix: allow unauthenticated CORS preflight for embedded bots #32884

Closed
opened 2026-02-21 20:52:15 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/30587

State: closed
Merged: Yes


<html>

Summary

This PR fixes a CORS regression that prevents Dify bots from being embedded on external websites.

Starting from recent versions, embedded bots fail due to rejected CORS preflight requests.
This change introduces a minimal, unauthenticated CORS configuration for embedded bot endpoints while keeping existing authentication and security behavior for console and service APIs unchanged.

Fixes #30440


Screenshots

Before | After -- | -- Embedded bot fails with CORS / connection refused | Embedded bot loads and responds correctly

Checklist

  • This change requires a documentation update, included: Dify Document

  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)

  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.

  • I've updated the documentation accordingly.

  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

</html>Summary

This PR fixes a CORS regression that prevents Dify bots from being embedded on external websites.

Starting from recent versions, embedded bots fail due to rejected CORS preflight requests.
This change introduces a minimal, unauthenticated CORS configuration for embedded bot endpoints while keeping existing authentication and security behavior for console and service APIs unchanged.

Fixes #30440

This change requires a documentation update, included: Dify Document

I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)

I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.

I've updated the documentation accordingly.

I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

**Original Pull Request:** https://github.com/langgenius/dify/pull/30587 **State:** closed **Merged:** Yes --- <html> <body> <!--StartFragment--><h2 data-start="428" data-end="438">Summary</h2> <p data-start="440" data-end="537">This PR fixes a CORS regression that prevents Dify bots from being embedded on external websites.</p> <p data-start="539" data-end="827">Starting from recent versions, embedded bots fail due to rejected CORS preflight requests.<br data-start="629" data-end="632"> This change introduces a minimal, unauthenticated CORS configuration for embedded bot endpoints while keeping existing authentication and security behavior for console and service APIs unchanged.</p> <p data-start="829" data-end="845"><strong data-start="829" data-end="845">Fixes #30440</strong></p> <hr data-start="847" data-end="850"> <h2 data-start="852" data-end="866">Screenshots</h2> <div class="TyagGW_tableContainer"><div tabindex="-1" class="group TyagGW_tableWrapper flex w-fit flex-col-reverse"> Before | After -- | -- Embedded bot fails with CORS / connection refused | Embedded bot loads and responds correctly </div></div> <hr data-start="1005" data-end="1008"> <h2 data-start="1010" data-end="1022">Checklist</h2> <ul class="contains-task-list" data-start="1024" data-end="1569"> <li class="task-list-item" data-start="1024" data-end="1141"> <p data-start="1030" data-end="1141"><input disabled="" type="checkbox"> This change requires a documentation update, included: <a data-start="1085" data-end="1141" rel="noopener" target="_new" class="decorated-link" href="https://github.com/langgenius/dify-docs">Dify Document<span aria-hidden="true" class="ms-0.5 inline-block align-middle leading-none"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" data-rtl-flip="" class="block h-[0.75em] w-[0.75em] stroke-current stroke-[0.75]"><use href="/cdn/assets/sprites-core-i9agxugi.svg#304883" fill="currentColor"></use></svg></span></a></p> </li> <li class="task-list-item" data-start="1142" data-end="1270"> <p data-start="1148" data-end="1270"><input disabled="" type="checkbox" checked=""> I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)</p> </li> <li data-start="1271" data-end="1395" class="task-list-item"> <p data-start="1277" data-end="1395"><input disabled="" type="checkbox" checked=""> I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.</p> </li> <li class="task-list-item" data-start="1396" data-end="1445"> <p data-start="1402" data-end="1445"><input disabled="" type="checkbox" checked=""> I've updated the documentation accordingly.</p> </li> <li data-start="1446" data-end="1569" class="task-list-item"> <p data-start="1452" data-end="1569"><input disabled="" type="checkbox" checked=""> I ran <code data-start="1458" data-end="1469">make lint</code> and <code data-start="1474" data-end="1491">make type-check</code> (backend) and <code data-start="1506" data-end="1533">cd web &amp;&amp; npx lint-staged</code> (frontend) to appease the lint gods</p></li></ul><!--EndFragment--> </body> </html>Summary This PR fixes a CORS regression that prevents Dify bots from being embedded on external websites. Starting from recent versions, embedded bots fail due to rejected CORS preflight requests. This change introduces a minimal, unauthenticated CORS configuration for embedded bot endpoints while keeping existing authentication and security behavior for console and service APIs unchanged. Fixes #30440 This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. I've updated the documentation accordingly. I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:52:15 -05:00
yindo closed this issue 2026-02-21 20:52:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32884