📌 Description
app.ts mounts the cors middleware with config.corsOrigins (or unrestricted, if unset), but there's no apparent test exercising an actual OPTIONS preflight request against a mutating route (e.g. POST /api/v1/anchors) to confirm the configured corsOrigins allowlist is actually honored by the cors package's preflight response headers.
🧩 Requirements and context
- Add a test booting
createApp() with CORS_ORIGIN set to a specific origin, issuing an OPTIONS preflight to a mutating route with a matching Origin header, and asserting Access-Control-Allow-Origin reflects it.
- Add a test with a non-matching
Origin header asserting the header is absent/doesn't reflect the disallowed origin.
- Add a test with
CORS_ORIGIN unset asserting the current unrestricted-origin behavior (documented in config.ts) still holds.
🛠️ Suggested execution
- Add tests to
src/config.test.ts-adjacent app-level tests or a new cors.test.ts, constructing createApp() under each CORS_ORIGIN configuration and issuing supertest OPTIONS requests.
✅ Acceptance criteria
🔒 Security notes
Verifies the CORS allowlist configuration actually takes effect at the HTTP layer, not just in config.ts's parsing logic — a misconfigured or silently-ignored CORS setting is a real cross-origin exposure risk.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
app.tsmounts thecorsmiddleware withconfig.corsOrigins(or unrestricted, if unset), but there's no apparent test exercising an actualOPTIONSpreflight request against a mutating route (e.g.POST /api/v1/anchors) to confirm the configuredcorsOriginsallowlist is actually honored by thecorspackage's preflight response headers.🧩 Requirements and context
createApp()withCORS_ORIGINset to a specific origin, issuing anOPTIONSpreflight to a mutating route with a matchingOriginheader, and assertingAccess-Control-Allow-Originreflects it.Originheader asserting the header is absent/doesn't reflect the disallowed origin.CORS_ORIGINunset asserting the current unrestricted-origin behavior (documented inconfig.ts) still holds.🛠️ Suggested execution
src/config.test.ts-adjacent app-level tests or a newcors.test.ts, constructingcreateApp()under eachCORS_ORIGINconfiguration and issuing supertestOPTIONSrequests.✅ Acceptance criteria
🔒 Security notes
Verifies the CORS allowlist configuration actually takes effect at the HTTP layer, not just in
config.ts's parsing logic — a misconfigured or silently-ignored CORS setting is a real cross-origin exposure risk.📋 Guidelines