Skip to content

Improve CORS config #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025
Merged

Improve CORS config #66

merged 1 commit into from
Jun 3, 2025

Conversation

doringeman
Copy link
Contributor

@doringeman doringeman commented Jun 2, 2025

Allow passing a list of allowed origins or retrieve them from DMR_ORIGINS.

You can test this with https://github.com/ilopezluna/chat2cart/tree/streaming and the following patch:

diff --git a/web/static/js/chat.js b/web/static/js/chat.js
index 1ecb6f0..0c6ccec 100644
--- a/web/static/js/chat.js
+++ b/web/static/js/chat.js
@@ -637,11 +637,11 @@ async function updateModelSelector(provider) {
             let endpoint;
             if (provider === 'dmr') {
                 // Use backend endpoint for DMR models
-                endpoint = '/api/v1/models/dmr';
+                endpoint = 'http://localhost:12434/engines/v1/models';
                 const response = await fetch(endpoint);
                 if (response.ok) {
                     const data = await response.json();
-                    models = data.models.map(model => ({
+                    models = data.data.map(model => ({
                         id: model.id,
                         name: model.id // Use the model ID as the display name
                     }));
  • Disable CORS by not setting DMR_ORIGINS with MODEL_RUNNER_PORT=12434 make run.
  • Enable CORS for all with DMR_ORIGINS=* MODEL_RUNNER_PORT=12434 make run.
  • Enable it for a specific origin with DMR_ORIGINS=http://localhost:3131 MODEL_RUNNER_PORT=12434 make run (run chat2cart on port 3131).
    By default, it will restrict all.

Allow passing a list of allowed origins or retrieve them from DMR_ORIGINS.

Signed-off-by: Dorin Geman <dorin.geman@docker.com>
@doringeman doringeman merged commit 8aa7a28 into docker:main Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants