Last active
February 23, 2022 09:42
-
-
Save zuohuadong/11892c2bb257a85fcec8362078a8e24d to your computer and use it in GitHub Desktop.
caddy proxy
This file contains 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 method OPTIONS | |
@cors header Origin {args.0} | |
handle @cors_preflight { | |
header Access-Control-Allow-Origin "{args.0}" | |
header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE" | |
header Access-Control-Allow-Headers "Content-Type" | |
header Access-Control-Max-Age "3600" | |
respond "" 204 | |
} | |
handle @cors { | |
header Access-Control-Allow-Origin "{args.0}" | |
header Access-Control-Expose-Headers "Link" | |
} | |
} | |
:8081 { | |
import cors http://0.0.0.0:8081 | |
reverse_proxy localhost:3000 | |
} |
This file contains 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
:8081 { | |
@options { | |
method OPTIONS | |
} | |
header { | |
Access-Control-Allow-Origin * | |
Access-Control-Allow-Credentials true | |
Access-Control-Allow-Methods * | |
Access-Control-Allow-Headers * | |
defer | |
} | |
reverse_proxy localhost:8080 { | |
header_down -Access-Control-Allow-Origin | |
} | |
respond @options 204 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment