home / skills / ehtbanton / claudeskillsrepo / cors-config-generator
This skill generates complete CORS configuration for APIs, delivering valid TypeScript middleware to enforce cross-origin access across origins.
npx playbooks add skill ehtbanton/claudeskillsrepo --skill cors-config-generatorReview the files below or copy the command above to add this skill to your agents.
---
name: cors-config-generator
description: Generate CORS configuration files for API cross-origin resource sharing. Triggers on "create cors config", "generate cors configuration", "cors setup", "cross-origin config".
---
# CORS Config Generator
Generate CORS configuration for API cross-origin access control.
## Output Requirements
**File Output:** `cors.ts` or CORS middleware configuration
**Format:** Valid TypeScript/JavaScript
**Standards:** CORS specification
## When Invoked
Immediately generate a complete CORS configuration for the API.
## Example Invocations
**Prompt:** "Create CORS config for production API"
**Output:** Complete CORS middleware with origin validation.
This skill generates ready-to-use CORS configuration files or middleware for TypeScript/JavaScript APIs. It produces valid CORS middleware (e.g., cors.ts) that implements origin validation, allowed methods, headers, credentials, and preflight handling. The output follows the CORS specification and is suitable for immediate integration into Express, Fastify, or similar servers.
When triggered it inspects the invocation intent and generates a complete CORS config file or middleware snippet. It includes origin matching (string, regex, or function), method and header allowlists, credentials policy, max-age, and preflight response settings. The generated TypeScript is self-contained and includes comments for integration points and small helper utilities for dynamic origin checks.
Will the generated config work with both Express and Fastify?
Yes. The skill can output a framework-agnostic middleware snippet and small adapters or a ready-to-drop-in config for Express or Fastify.
Can it generate dynamic origin checks for multi-tenant apps?
Yes. The output can include a function-based origin validator that checks request origin against tenant data or environment variables.