fix: scope CORS command to current preview origin

Replace wildcard * with window.location.origin so the
displayed command only opens the backend to this deployment,
not every origin.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
snomiao
2026-04-14 00:25:11 +09:00
parent 4764a0850c
commit 30ce606b0a
2 changed files with 6 additions and 3 deletions

View File

@@ -101,7 +101,9 @@ describe('ConnectionPanelView', () => {
it('displays the comfy launch command', () => {
renderPanel()
expect(
screen.getByText('comfy launch -- --enable-cors-header="*"')
screen.getByText(
`comfy launch -- --enable-cors-header="${window.location.origin}"`
)
).toBeTruthy()
})

View File

@@ -160,7 +160,7 @@
<code
class="block rounded-md bg-neutral-800 p-3 text-xs text-neutral-200 select-all"
>
comfy launch -- --enable-cors-header="*"
comfy launch -- --enable-cors-header="{{ corsOrigin }}"
</code>
</div>
</div>
@@ -198,7 +198,7 @@
<code
class="block rounded-md bg-neutral-800 p-3 text-xs text-neutral-200 select-all"
>
python main.py --enable-cors-header="*"
python main.py --enable-cors-header="{{ corsOrigin }}"
</code>
</div>
</div>
@@ -248,6 +248,7 @@ const { t } = useI18n()
const DEFAULT_BACKEND_URL = 'http://127.0.0.1:8188'
const STORAGE_KEY = 'comfyui-preview-backend-url'
const REPO = 'https://github.com/Comfy-Org/ComfyUI_frontend'
const corsOrigin = window.location.origin
const backendUrl = ref(localStorage.getItem(STORAGE_KEY) || DEFAULT_BACKEND_URL)