Golem Add Cors Scala
Developmentgolem-add-cors-scalaGolem Add Cors Scala is an Agent Skill for development published in the golemcloud/golem repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Configuring CORS for Scala HTTP endpoints. Use when the user asks to enable CORS, allow cross-origin requests, or configure allowed origins for HTTP endpoints.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/golemcloud/golem/blob/HEAD/golem-skills/skills/scala/golem-add-cors-scala/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/golem-add-cors-scala, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Configuring CORS for Scala HTTP Endpoints
Mount-Level CORS
Set cors on @agentDefinition to apply allowed origins to all endpoints:
@agentDefinition(
mount = "/api/{value}",
cors = Array("https://app.example.com")
)
trait MyAgent extends BaseAgent {
class Id(val value: String)
@endpoint(method = "GET", path = "/data")
def getData(): Future[String]
// 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:
@agentDefinition(
mount = "/api/{value}",
cors = Array("https://app.example.com")
)
trait MyAgent extends BaseAgent {
class Id(val value: String)
@endpoint(method = "GET", path = "/data", cors = Array("*"))
def getData(): Future[String]
// Allows BOTH https://app.example.com AND * (all origins)
@endpoint(method = "GET", path = "/other")
def getOther(): Future[String]
// Inherits mount-level: only https://app.example.com
}
Wildcard
Use "*" to allow all origins:
@agentDefinition(
mount = "/public/{value}",
cors = Array("*")
)
trait PublicAgent extends BaseAgent {
class Id(val value: 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.