Configuring CORS for Rust HTTP Endpoints

SkillDev tools

Configuring CORS for Rust HTTP endpoints. Use when the user asks to enable CORS, allow cross-origin requests, or configure allowed origins for HTTP endpoints.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Configuring CORS for Rust HTTP Endpoints skill

What this skill tells your AI

The instructions your AI receives, as published by golemcloud/golem in golem-skills/skills/rust/golem-add-cors-rust/SKILL.md and read by ahel’s review.

Mount-Level CORS

Set cors on #[agent_definition] to apply allowed origins to all endpoints:

#[agent_definition(
    mount = "/api/{name}",
    cors = ["https://app.example.com"]
)]
pub trait MyAgent {
    fn new(name: String) -> Self;

    #[endpoint(get = "/data")]
    fn get_data(&self) -> Data;
    // Allows https://app.example.com
}

Endpoint-Level CORS

Set cors on #[endpoint] to add allowed origins for a specific endpoint. Origins are unioned with mount-level CORS:

#[agent_definition(
    mount = "/api/{name}",
    cors = ["https://app.example.com"]
)]
pub trait MyAgent {
    fn new(name: String) -> Self;

    #[endpoint(get = "/data", cors = ["*"])]
    fn get_data(&self) -> Data;
    // Allows BOTH https://app.example.com AND * (all origins)

    #[endpoint(get = "/other")]
    fn get_other(&self) -> Data;
    // Inherits mount-level: only https://app.example.com
}

Wildcard

Use "*" to allow all origins:

#[agent_definition(mount = "/public/{name}", cors = ["*"])]
pub trait PublicAgent {
    fn new(name: String) -> Self;
}

CORS Preflight

Golem automatically handles OPTIONS preflight requests for endpoints that have CORS configured. The preflight response includes Access-Control-Allow-Origin, Access-Control-Allow-Methods, and Access-Control-Allow-Headers headers.

Signals

GitHub stars
2k
Forks
212
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
golem-add-cors-rust
Source
github.com/golemcloud/golem