Skip to content

Instantly share code, notes, and snippets.

@ball6847
Created February 6, 2024 08:02
Show Gist options
  • Save ball6847/1babde85efac620ecd1846a9dbf7ba5b to your computer and use it in GitHub Desktop.
Save ball6847/1babde85efac620ecd1846a9dbf7ba5b to your computer and use it in GitHub Desktop.
Simple caddyfile with cors enabled for local development
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
defer
}
respond "" 204
}
handle @cors{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Expose-Headers *
defer
}
}
}
http://localhost {
handle {
import cors http://localhost:8000
reverse_proxy backend:8080
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment