Last active
February 1, 2018 06:30
-
-
Save vyshane/ae38a21e3d81b97da0b90606d099346a to your computer and use it in GitHub Desktop.
GCP's Extensible Service Proxy cannot do Cross-Origin Resource Sharing. We put a HAProxy in front of it to handle CORS.
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
# Add CORS headers when Origin header is present | |
capture request header origin len 128 | |
http-response set-header Access-Control-Allow-Origin %[capture.req.hdr(0)] if { capture.req.hdr(0) -m found } | |
http-response set-header Access-Control-Allow-Methods GET,\ HEAD,\ OPTIONS,\ POST,\ PUT if { capture.req.hdr(0) -m found } | |
http-response set-header Access-Control-Allow-Credentials true if { capture.req.hdr(0) -m found } | |
http-response set-header Access-Control-Allow-Headers Origin,\ Accept,\ X-Requested-With,\ Content-Type,\ Access-Control-Request-Method,\ Access-Control-Request-Headers,\ Authorization if { capture.req.hdr(0) -m found } | |
# Google Cloud Platform ESP does not support CORS | |
# We want to return a 204 regardless | |
http-response set-status 204 if { capture.req.hdr(0) -m found } METH_OPTIONS | |
http-response set-header Content-Type text/plain;\ charset=utf-8 if { capture.req.hdr(0) -m found } METH_OPTIONS | |
http-response set-header Content-Length 0 if { capture.req.hdr(0) -m found } METH_OPTIONS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment