-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug with CORS headers #57
Conversation
5961b65
to
b48a181
Compare
07edcdd
to
f060113
Compare
f060113
to
16cea28
Compare
DEFAULT_ACCESS_CONTROL_ALLOW_ORIGIN_VALUE="*" | ||
# Map contains mapping between hostname (for ex. evm.kava.io) and corresponding value for Access-Control-Allow-Origin header. | ||
# If hostname for specific request is missing we fallback to DEFAULT_ACCESS_CONTROL_ALLOW_ORIGIN_VALUE. | ||
# NOTE: it will be used only in Cache Hit scenario. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update caching docs with details on how the cachng middleware affects headers and logic for deciding when to modify cors headers
@@ -254,6 +254,11 @@ func createProxyRequestMiddleware(next http.Handler, config config.Config, servi | |||
for headerName, headerValue := range typedCachedResponse.HeaderMap { | |||
w.Header().Add(headerName, headerValue) | |||
} | |||
// add CORS headers | |||
accessControlAllowOriginValue := config.GetAccessControlAllowOriginValue(r.Host) | |||
if accessControlAllowOriginValue != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important to add to the spec in the caching doc that we won't override any value of this header if present from the backend response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually in current implementation we override
I can add smth like this:
// add CORS headers
accessControlAllowOriginValue := config.GetAccessControlAllowOriginValue(r.Host)
if w.Header().Get("Access-Control-Allow-Origin") == "" && accessControlAllowOriginValue != "" {
w.Header().Add("Access-Control-Allow-Origin", accessControlAllowOriginValue)
}
@galxy25 ?
d3e4dd2
to
5663879
Compare
No description provided.