open-notebook/api
Luis Novo e5381b0c49
feat(api): limit CORS to localhost and the same host when no password is set (#1556)
* feat(api): allow only localhost CORS origins when no password is set

Without OPEN_NOTEBOOK_PASSWORD the API has no authentication, and the
default CORS wildcard let any web page the user visits call it through
their browser and read the answers. While CORS_ORIGINS is unset and no
password is set, the default now admits only localhost, 127.0.0.1 and
[::1] origins. With a password the default stays '*', and an explicit
CORS_ORIGINS always wins. The shipped UI goes through its own origin and
is unaffected. Recorded in ADR-014.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(api): allow same-host CORS origins when no password is set

The localhost-only default broke the default UI opened from another
machine: with API_URL unset, /config points the browser at
<host>:5055 from the page on port 8502, which is cross-origin. Without
a password, the default now also admits origins whose host name equals
the request's Host, so LAN and VPS installs keep working while other
sites still can't read the API's answers.

Also treats a blank CORS_ORIGINS as unset, adds positive preflight and
same-host tests, names OPEN_NOTEBOOK_PASSWORD_FILE in the docs, and
states that CORS is not authentication.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFiTN3BrhD1rr799jJfi5S

* docs(cors): state same-host and DNS-rebinding limits of the no-password default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFiTN3BrhD1rr799jJfi5S

* docs(cors): say an explicit CORS_ORIGINS replaces the default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFiTN3BrhD1rr799jJfi5S

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 21:07:58 -03:00
..
routers fix(notebooks): stop linking the same source to a notebook twice (#1533) 2026-11-07 20:34:50 -03:00
__init__.py Api podcast migration (#93) 2025-07-17 08:36:11 -03:00
AGENTS.md docs: development docs match the codebase; add-a-provider playbook (#1458) 2026-10-04 23:06:36 -03:00
auth.py fix(auth): accept UTF-8 passwords (#1344) 2026-09-11 01:00:06 +00:00
CLAUDE.md docs: development docs match the codebase; add-a-provider playbook (#1458) 2026-10-04 23:06:36 -03:00
command_service.py refactor(api): remove dead Streamlit-era service layer and demo commands (#1054) 2026-07-11 18:17:44 -03:00
cors.py feat(api): limit CORS to localhost and the same host when no password is set (#1556) 2026-11-07 21:07:58 -03:00
credentials_service.py feat(providers): MiniMax text-to-speech and MiniMax-M3 (#1444) 2026-10-03 23:19:28 -03:00
main.py feat(api): limit CORS to localhost and the same host when no password is set (#1556) 2026-11-07 21:07:58 -03:00
middleware.py fix: reject oversized request bodies before auth/routing (#1014) 2026-07-10 11:15:18 -03:00
models.py feat(providers): add SiliconFlow and Z.ai (#1443) 2026-10-03 23:13:25 -03:00
podcast_service.py fix(podcasts): reference speaker profiles by record ID instead of name (#1110) 2026-07-12 13:05:04 -03:00