feat(registry): configure CORS headers - #1545
Merged
ricardo-devis-agullo merged 2 commits intoAug 9, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds configurable CORS response headers to the registry while retaining existing defaults.
Changes:
- Adds typed CORS configuration, normalization, and validation.
- Applies configured headers through registry middleware.
- Adds unit, HTTP adapter, and type coverage.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/oc/src/types.ts |
Defines CORS configuration types. |
packages/oc/src/index.ts |
Exports public CORS types. |
packages/oc/src/resources/index.ts |
Adds CORS validation messages. |
packages/oc/src/registry/middleware/cors.ts |
Validates, normalizes, and applies CORS headers. |
packages/oc/src/registry/domain/options-sanitiser.ts |
Normalizes registry CORS options. |
packages/oc/src/registry/domain/validators/registry-configuration.ts |
Validates CORS configuration before startup. |
packages/oc/test/unit/registry-middleware-cors.js |
Tests default and custom HTTP headers. |
packages/oc/test/unit/registry-domain-validator.js |
Tests invalid CORS options. |
packages/oc/test/unit/registry-domain-options-sanitiser.js |
Tests defaults and normalization. |
packages/oc/test/types/registry-cors.ts |
Verifies public TypeScript usage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| 'Origin, X-Requested-With, Content-Type, Accept, traceparent' | ||
| ); | ||
| res.set('Access-Control-Allow-Methods', 'GET, OPTIONS, PUT, POST'); | ||
| res.set('Access-Control-Allow-Credentials', String(options.credentials)); |
Collaborator
Author
There was a problem hiding this comment.
Addressed in 43295cb: Access-Control-Allow-Credentials is now emitted only when cors.credentials is true; the custom HTTP adapter test verifies the header is absent when disabled.
ricardo-devis-agullo
deleted the
feat/configurable-cors-security-headers
branch
August 9, 2026 19:34
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
corsconfiguration for origin, credentials, allowed headers, and methodsX-Powered-Bydefaults exactlyTest plan
npm run build --workspace=ocnpx tsc --project packages/oc/tsconfig.types.jsonnpx mocha ./test/unit/registry-domain-options-sanitiser.js ./test/unit/registry-domain-validator.js ./test/unit/registry-middleware-cors.jsfrompackages/oc(158 passing)npm run test-silent --workspace=oc(982 passing)git diff --check