Configuring CORS for MoonBit HTTP Endpoints
SkillAI & modelsConfiguring CORS allowed origins for HTTP endpoints in MoonBit Golem agents. Use when the user asks to enable CORS, allow cross-origin requests, or configure allowed origins.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Configuring CORS for MoonBit HTTP Endpoints skill
What this skill tells your AI
The instructions your AI receives, as published by golemcloud/golem in golem-skills/skills/moonbit/golem-add-cors-moonbit/SKILL.md and read by ahel’s review.
Mount-Level CORS
Set #derive.mount_cors(...) on the agent struct to apply allowed origins to all endpoints:
#derive.agent
#derive.mount("/api/{name}")
#derive.mount_cors("https://app.example.com")
pub(all) struct MyAgent {
name : String
}
fn MyAgent::new(name : String) -> MyAgent {
{ name }
}
#derive.endpoint(get="/data")
pub fn MyAgent::get_data(self : Self) -> String {
// Allows https://app.example.com
"data"
}
Multiple origins can be specified as separate arguments:
#derive.mount_cors("https://app.example.com", "https://other.example.com")
Endpoint-Level CORS
Set #derive.endpoint_cors(...) on a method to add allowed origins for a specific endpoint. Origins are unioned with mount-level CORS:
#derive.agent
#derive.mount("/api/{name}")
#derive.mount_cors("https://app.example.com")
pub(all) struct MyAgent {
name : String
}
fn MyAgent::new(name : String) -> MyAgent {
{ name }
}
#derive.endpoint(get="/data")
#derive.endpoint_cors("*")
pub fn MyAgent::get_data(self : Self) -> String {
// Allows BOTH https://app.example.com AND * (all origins)
"data"
}
#derive.endpoint(get="/other")
pub fn MyAgent::get_other(self : Self) -> String {
// Inherits mount-level: only https://app.example.com
"other"
}
Wildcard
Use "*" to allow all origins:
#derive.agent
#derive.mount("/public/{name}")
#derive.mount_cors("*")
pub(all) struct PublicAgent {
name : String
}
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-moonbit- Source
- github.com/golemcloud/golem