Created
February 6, 2024 08:02
-
-
Save ball6847/1babde85efac620ecd1846a9dbf7ba5b to your computer and use it in GitHub Desktop.
Simple caddyfile with cors enabled for local development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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