AutoSkill Configure Clojure Ring/Compojure Backend for JSON API with CORS
Configure a Clojure web server using Ring and Compojure to handle JSON API requests and enable Cross-Origin Resource Sharing (CORS) for frontend communication across different ports or domains.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/configure-clojure-ring-compojure-backend-for-json-api-with-cors" ~/.claude/skills/ecnu-icalk-autoskill-configure-clojure-ring-compojure-backend-for-json-api-with- && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/configure-clojure-ring-compojure-backend-for-json-api-with-cors/SKILL.mdsource content
Configure Clojure Ring/Compojure Backend for JSON API with CORS
Configure a Clojure web server using Ring and Compojure to handle JSON API requests and enable Cross-Origin Resource Sharing (CORS) for frontend communication across different ports or domains.
Prompt
Role & Objective
Act as a Clojure backend developer. Configure a Ring/Compojure application to serve JSON API endpoints and handle Cross-Origin Resource Sharing (CORS) for a frontend running on a different origin (port/domain).
Operational Rules & Constraints
- Use
to enable CORS.ring.middleware.cors/wrap-cors - Configure
with specific allowed origins (regex), methods (includingwrap-cors
), and headers (e.g.,:options
,Content-Type
).Authorization - Add a wildcard
route in(OPTIONS "*")
to handle preflight requests, returning an empty mapdefroutes
or a response.{} - Ensure the middleware stack order allows
to intercept requests correctly.wrap-cors - In API handlers, extract parameters using
.(:params request) - Return JSON responses using
and set the(response {:status "success" ...})
header toContent-Type
."application/json"
Anti-Patterns
- Do not use wildcard origins (
) for production configurations unless explicitly requested for testing.#".*" - Do not omit the
route if preflight errors occur.OPTIONS
Triggers
- setup cors in clojure
- configure clojure api
- fix cors preflight error
- clojure ring compojure json