Skip to content

Add CORS configuration guide and examples #55

@PAMulligan

Description

@PAMulligan

Description

Create a dedicated guide for CORS configuration in Nerva APIs. The pipeline config sets CORS defaults (`origins: ["*"]`), but there's no documentation explaining how to configure CORS for different environments.

Why

CORS misconfiguration is one of the most common API deployment issues. New developers frequently struggle with CORS errors. A dedicated guide with environment-specific examples (development wildcard, production allowlist) prevents hours of debugging.

Current State

`pipeline.config.json`:
```json
"cors": {
"enabled": true,
"origins": ["*"],
"methods": ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
"allowHeaders": ["Content-Type", "Authorization", "X-API-Key"],
"maxAge": 86400
}
```

Acceptance Criteria

  • Create `docs/api-development/cors-configuration.md`
  • Cover:
    • What CORS is and why it exists (brief)
    • How Hono's `cors()` middleware works
    • Development configuration (wildcard `*`)
    • Production configuration (explicit origin allowlist)
    • Credentials mode (`Access-Control-Allow-Credentials`)
    • Preflight caching (`maxAge`)
    • Common CORS errors and how to debug them
    • Cloudflare Workers CORS considerations
  • Include code examples for each configuration
  • Link from `docs/api-development/README.md`
  • CI passes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions