mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4801
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3853
Author: @MaKla89
Created: 10/23/2026
Status: ❌ Closed
Base:
main← Head:fix-3208-share-cors📝 Commits (1)
1dc28d7App sharing: the shared and tunnel listener answers browser CORS when an API key is set - the preflight (OPTIONS, which never carries the key) before the path and key checks, Access-Control headers on every answer; without a key nothing changes, so a keyless share still reaches devices on the network only and no web page of another site can read the model; regression tests and the DETAILS CORS line (#3208)📊 Changes
3 files changed (+104 additions, -3 deletions)
View changed files
📝
apps/host/server/local-share.mjs(+15 -1)➕
apps/host/tests/cors-share.test.mjs(+83 -0)📝
docs/DETAILS.md(+6 -2)📄 Description
… an API key is set - the preflight (OPTIONS, which never carries the key) before the path and key checks, Access-Control headers on every answer; without a key nothing changes, so a keyless share still reaches devices on the network only and no web page of another site can read the model; regression tests and the DETAILS CORS line (#3208)
Problem and result
A browser page on another machine cannot call the app's API over the local network. The
browser's CORS preflight (
OPTIONS) gets401 Invalid API key, and no answer carriesAccess-Control-Allow-Origin, so the browser blocks the call. The API itself is fine —the same request with a key returns the model list.
This is the case in #3208: a chatbot page served from a NAS, calling the app's shared
address (port 47832) from a browser on another device.
The app has two listeners, and only one of them handled CORS:
127.0.0.1, port 47831 or the next free one) setsAccess-Control-Allow-Origin: *and answersOPTIONS— but the desktop shell starts iton loopback only (
STRATA_BIND=127.0.0.1inapps/desktop/src-tauri/src/main.rs), so asecond device can never reach it;
0.0.0.0, the address shown under Serving when you share) is the oneother devices use, and it sent no CORS headers at all. It passed
OPTIONSstraight toopenai(), which checks the API key first — and a browser never sends a key on apreflight, so every preflight failed.
After this change the preflight is answered and every answer carries the CORS headers, so
the browser lets the call through. The key still decides who gets an answer.
Related discussion
#3208. The reporter's probes there (2026-10-21) are the reproduction, and they match what I
measured at v0.2.3.1 (see Validation). The 0.2.1 help text (
d8a6a0e) says the app's API"already allows pages of any site"; that is true for the loopback listener and not for the
shared address a second device has to use.
Approach
apps/host/server/local-share.mjsanswers the preflight and sets the headers, before thepath allowlist and the key check:
OPTIONS→204, because a browser sends no key with a preflight (the spec says so).The request that follows still goes through the path check and the key check, so a
preflight grants nothing:
/api/*stays 404 on this listener.Access-Control-Allow-Origin: *,Allow-Methods: GET, POST, OPTIONS,Allow-Headers(the list the preflight asks for, else the headers the SDKs and Anthropic browser clients
send),
Max-Age: 600— the same shape the engine's own server uses (serve/server.py,_cors()). Set withsetHeaderbefore dispatch, so the 404, 401 and 500 answers carrythem too; a browser then sees the real 401 instead of a CORS wall.
sends no CORS headers. That keeps the promise in SECURITY.md and in the app's own warning:
a keyless share reaches devices on your network, and a web page of another site cannot
read your model through it. A page can point its own name at a LAN address, and this
listener has no Host check, so unconditional
*would have widened that. With a key thekey decides, and
*is safe: the browser cannot produce the key, and the preflight itselfanswers nothing.
No new setting, nothing to switch on. The app's own listener,
openai(),serving.authorized(), theserver.corsexpert switch and its help text in eight languagesare untouched, so the default path is unchanged. The Cloudflare tunnel listener is the same
factory and is fixed by the same change.
Changed files:
apps/host/server/local-share.mjs(+15),apps/host/tests/cors-share.test.mjs(new, 4 checks),
docs/DETAILS.md(the CORS paragraph). One commit,1dc28d7b, on v0.2.3.1.Validation
Revision:
1dc28d7b(one commit on7ddc17a3/ tag v0.2.3.1). Environment: Linux x86_64,Node 24.22.1, npm 11.19.1, no GPU model loaded (simulated engine).
Passed
npm ci && npm testinapps/host: 1081 tests, 976 passed, 1 failed (below), 104 skipped.The skips are gated on this machine: 97 need
STRATA_HARNESS_DIR(a built Harness), oneneeds
STRATA_TEST_BROWSER=1, one is the Windows PowerShell check.The reporter's probes, run against a real host with sharing switched on through the app's
own route (
POST /api/serving/share {enabled:true}), an API key set, and the probes sentto the share port. Same script, same probes, both revisions:
7ddc17a3)1dc28d7b)OPTIONS /v1/models,Origin+Access-Control-Request-*, no auth401, no CORS headers204,allow-origin: *,allow-methods,allow-headers: authorization,content-type(echoed),max-age: 600GET /v1/models+ key +Origin200, noAccess-Control-Allow-Origin200+access-control-allow-origin: *GET /v1/models, no key401, no CORS headers401+ the CORS headersGET /api/servingon the share port404404The left column reproduces the table in #3208 line for line.
New
apps/host/tests/cors-share.test.mjs: preflight answered without a key and therequested headers echoed;
Access-Control-Allow-Originon the 200 and on the 401; apreflight grants nothing (
/api/tasksstill 404); and with no key set nothing changes —no CORS headers anywhere, and the keyless share still answers a device on the network.
One check that the headers survive the handlers:
setHeaderbefore a handler'swriteHead(status, {...})keeps both (Node 24, small probe), and a header the handlersets itself wins over the listener's. That is why no handler needed changing.
Failed
apps/host/tests/timeskip-real.test.mjs→ "Stop ends the job and everything it started,deletes the copies, leaves the person's files alone, and the run then reads as cancelled":
AssertionError: the revision command (a grandchild of the job) was ended too. It failsthe same way at
7ddc17a3in a clean worktree, and the test never touches the changedcode. Pre-existing on this machine, not from this change.
Not run
apps/hosttests.scripts-test.ymlcovers.github/scriptsonly, and its paths do not match this change. So the runs above are the whole evidence.
writeHeadpath is covered by thecheck above and by reading, not by a live run. Needs a machine with a card.
Limits
openai()'sJSON path. The native gateway path is verified by reading and by the header check, not by
a live model.
Access-Control-Allow-Origin: *means cookies are never usable here; the API is keyed byheader only, which is what OpenAI- and Anthropic-style browser clients send.
cors_originsstill belongs to the engine's own server only. This change does not letanyone limit origins on the app's shared address: with a key set, any page may call it,
and the key is the gate. A per-origin list there would be a separate feature.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.