chproxy
chproxy copied to clipboard
allow_cors may break CORS
users[].allow_cors = true may lead to multiple Access-Control-Allow-Origin headers
Actual behaviour:
Responses with multiple headers is rejected by Chrome browser with following error:
The 'Access-Control-Allow-Origin' header contains multiple values 'http://ui.tabix.io, *', but only one is allowed.
Steps to reproduce:
-
add_http_cors_header = 1is default behaviour for tabix.io and grafana-clickhouse plugin, also it may be set as default for some users. - In this case clickhouse-server responses includes
Access-Control-Allow-Origin: *header. - Setting chproxy option
users[].allow_cors = trueleads to injecting secondAccess-Control-Allow-Origin: originheader. - Response that contains two CROS headers and is rejected by Chrome
Access-Control-Allow-Origin: * # by clickhouse-server Access-Control-Allow-Origin: http://ui.tabix.io # by chproxy
Expected behaviour
One of this
- don't add Allow-Origin header is response already has one
-
- if
users[].allow_cors = truethen drop all Allow-Origin headers in source response if any and write single Allow-Origin header in same manner as chproxy does now - if
users[].allow_cors = falsethen do nothing (user may expect that add_http_cors_header will take effect and experience troubles if chproxy changes this behaviour)
- if
For me option 2 looks way better, at least because it respects real Origin header value from client
Thanks for so detailed report @nezed!
any updates on this?
@hagen1778 any updates on this?