feat: CORS allowlist for cross-origin HTTP clients#1
Closed
jonpepler wants to merge 2 commits into
Closed
Conversation
Configurable via a new ALLOWED_ORIGINS setting in
PluginConfiguration. Empty list (the default) preserves the
historical behaviour of never sending CORS headers, so existing
setups are unaffected.
When configured, the server:
- echoes the request's Origin in Access-Control-Allow-Origin
if it matches the allowlist (with Vary: Origin), rather than
emitting a wildcard
- responds 204 to OPTIONS preflight with standard
methods/headers
- leaves non-allowlisted requests untouched, so browsers
block-by-default
Lets dashboards and SPAs hosted on a different origin (e.g.
GitHub Pages, a local Vite dev server) read action responses
without needing a same-origin proxy.
318e0e6 to
45f7f44
Compare
162ff30 to
44d1252
Compare
Owner
Author
|
Superseded by upstream PR TeaGuild#82 (re-targeting against TeaGuild) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a configurable CORS allowlist so dashboards / SPAs hosted on a different origin (GitHub Pages, a local Vite dev server, a phone on the LAN) can read Telemachus action responses without needing a same-origin proxy.
Behaviour
ALLOWED_ORIGINSsetting inPluginConfiguration(Telemachus/config.xml).OrigininAccess-Control-Allow-Originif it matches the allowlist, withVary: Origin. We echo rather than emit*— same permissiveness for configured clients, but blocks credentialed requests from arbitrary origins.Access-Control-Allow-Methods/Access-Control-Allow-Headers/Access-Control-Max-Age.Config example
Comma-separated. Trailing slashes and empty entries are stripped.
Test plan
Allowed CORS origins: …logs on init when config is set.curl -H "Origin: http://localhost:5173" -i http://127.0.0.1:8085/telemachus/datalink?a=v.altitudeshowsAccess-Control-Allow-Origin: http://localhost:5173+Vary: Origin.Access-Control-*headers.