fix(api): pin the container toolchain, drop root, and close the CORS origin wildcard - #36
Merged
Merged
Conversation
Replace golang:tip-alpine with the pinned 1.26.4 release used elsewhere in the repo, copy go.work.sum for reproducible builds, and switch the runtime stage to distroless/static-debian12:nonroot so the container no longer runs as root.
The old prefix+suffix check (https://pigo-web* + *.vercel.app) allows anyone who registers a Vercel project like pigo-web-anything to get a permanently allowed origin. Replace it with exact-match against the allowlist plus an explicit https://*.example.com wildcard syntax that matches a single subdomain label. Also set Vary: Origin on every response instead of only allowed-origin responses.
Cover exact-match, the prefix-spoof regression (pigo-web-evil.vercel.app), wildcard subdomain matching edge cases, and the Vary header behavior of the CORS middleware end to end.
Add apps/api/.env.example and a Configuration subsection in the README so the API's environment variables are no longer undocumented.
The API reads os.Getenv directly; nothing loads a .env file, so telling users to copy apps/api/.env.example to apps/api/.env had no effect. State that the API reads its settings from the process environment instead. Also tightens the CORS table cell to active voice.
|
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.
Why
What changed
Breaking change for previews
Vercel preview deployments are no longer allowed by default. Set `CORS_ALLOWED_ORIGINS` with your account-scoped wildcard, for example `https://*.your-team-projects.vercel.app`, which outsiders cannot register under.
Verification