fix: restrict CORS to trusted origins via ALLOWED_ORIGINS (#184) - #220
Open
cass-clearly wants to merge 1 commit into
Open
fix: restrict CORS to trusted origins via ALLOWED_ORIGINS (#184)#220cass-clearly wants to merge 1 commit into
cass-clearly wants to merge 1 commit into
Conversation
Closes #184. The server previously used `cors()` with no config, allowing requests from any origin. Now reads `ALLOWED_ORIGINS` (comma-separated) from the environment and defaults to `http://localhost:3333`. Credentials are enabled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
|
Review: Approved ✅ CORS restriction correctly implemented. Changes:
All tests pass. No issues found. |
cass-clearly
commented
Mar 17, 2026
cass-clearly
left a comment
Owner
Author
There was a problem hiding this comment.
Review: fix: restrict CORS to trusted origins
Verdict: Approve (posted as comment because GitHub blocks self-approval)
What's Good
- Clean, minimal change — single line in
server/index.jsthat does exactly what the issue asks ALLOWED_ORIGINSenv var with sensible default (http://localhost:3333) means zero friction for local dev- Docker Compose pass-through is correct and won't break existing deployments (default matches what they're already running)
- README env variable table is a nice improvement — fills a gap in the docs
credentials: trueis the right pairing with restricted origins for future cookie-based auth (#41)
Observations (non-blocking)
- Wildcard behavior: If someone sets
ALLOWED_ORIGINS=*, the current code createsorigin: ['*'](an array), whichcorsdoesn't treat as a wildcard — it would block all origins. Could add a note in the README or a guard, but edge case behavior is fine to leave for a follow-up. - Origin validation: No input validation on the env var value, but that's consistent with how the rest of the server config works.
This is exactly the right scope for a security fix. Approve.
This was referenced Mar 17, 2026
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.
What changed
server/index.js: Replaced opencors()with origin-restricted config usingALLOWED_ORIGINSenv vardocker-compose.remarq.yml: PassesALLOWED_ORIGINSto the server container (defaults tohttp://localhost:3333)README.md: Added Environment Variables table documentingDATABASE_URL,PORT, andALLOWED_ORIGINSWhy
Closes #184. The server used
app.use(cors())with no configuration, allowing requests from any origin. This is a security risk in production — CORS should restrict allowed origins to trusted domains.How to verify
Manual testing checklist
npm run test:server— 135 pass, 98.63% coverage)npm run lint)npm run format:check)🤖 Generated with Claude Code