developer-delphi-horse-cors

Configure CORS middleware for Horse APIs with preflight OPTIONS responses.

Updated Jan 6, 2026
One-click install
npx skills add https://github.com/cslsoftwares/ParamentersORM --skill developer-delphi-horse-cors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: developer-delphi-horse-cors
Source: https://github.com/cslsoftwares/ParamentersORM/tree/main/.cursor/skills/developer-delphi-horse-cors_V1.0.0
Command: npx skills add https://github.com/cslsoftwares/ParamentersORM --skill developer-delphi-horse-cors

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Middleware CORS for Horse: defines Access-Control-* headers and handles preflight OPTIONS with 204 No Content, enabling cross-origin requests for Horse-based APIs.

Core Features & Use Cases

  • Global configuration via HorseCORS() with chainable methods: AllowedOrigin, AllowedCredentials, AllowedHeaders, AllowedMethods, ExposedHeaders.
  • Proper preflight handling: responds to OPTIONS with 204 to unblock browser requests.
  • Pipeline order: should be the first middleware to ensure preflight requests aren't blocked by auth.

Quick Start

Initialize HorseCORS, configure AllowedOrigin, AllowedCredentials, AllowedHeaders, AllowedMethods and ExposedHeaders, register it as the first middleware, then start your Horse server.

Frequently Asked Questions about developer-delphi-horse-cors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add CORS support to a Horse web API in Delphi?

Add CORS support to a Horse web API by registering the HorseCORS middleware to configure allowed origins, credentials, headers, and methods. It automatically handles cross-origin preflight OPTIONS requests by returning a 204 No Content response.

Why does CORS preflight fail in my Delphi Horse backend when authentication is enabled?

CORS preflight requests fail when authentication middleware blocks OPTIONS requests before CORS headers are applied. You must register the HorseCORS middleware first in the pipeline so preflight requests are handled with a 204 response before auth checks.

How do I configure allowed origins and headers for cross-origin requests in Horse?

Configure allowed origins and headers for cross-origin requests in Horse by using the chainable HorseCORSConfig methods: AllowedOrigin, AllowedCredentials, AllowedHeaders, AllowedMethods, and ExposedHeaders during server initialization.

Does the Horse framework need a specific middleware order for CORS to work properly?

Yes, the Horse framework requires CORS middleware to be registered as the first middleware in the pipeline. This ordering ensures that preflight OPTIONS requests receive the correct Access-Control-* headers and a 204 response without being blocked by authentication.

What is a CORS preflight request and how does Horse handle it?

A CORS preflight request is an OPTIONS request sent by the browser to check server permissions before the actual cross-origin request. The Horse CORS middleware intercepts and responds to OPTIONS requests with a 204 No Content status and the appropriate Access-Control-* headers.

Can I expose custom response headers to the browser when using CORS with Horse?

Yes, you can expose custom response headers to the browser using the ExposedHeaders method within the HorseCORS configuration. This adds the necessary Access-Control-Expose-Headers entry to allow your frontend to read those custom headers.