regex - Using a regular expression with CORS -
i trying use regular expression cors. have read many times not possible cors (*) or exact domains. access-control-allow-origin wildcard subdomains, ports , protocols . seems contradict :http://www.cameronstokes.com/2010/12/26/cross-origin-resource-sharing-and-apache-httpd/. clarify , if using regular expression possible provide simple example have tried implement link above no success.
the regular expression wish use
^http\://\blocal-.*\b\.testing-test:10005$
i have checked regex , matches generated urls. have added setenvif , header set lines suggested apache2.conf (is correct?) follows
setenvif origin "^http\://\blocal-.*\b\.mycompany-it:10005$" accesscontrolalloworigin=$0 header add access-control-allow-origin % {accesscontrolalloworigin}e env=accesscontrolalloworigin
i lost next.it doesn't work in advance
access-control-allow-origin headers can wildcard '*' or exact url. 1 way first value of origin header request (this varies server server, 1 sample might like: request.headers['origin']
).
then regex check value of request origin. if request's origin passes check allowed regex expression, can set value of access-control-allow-origin value of request's origin (sample: response.headers['access-control-allow-origin'] = request.headers['origin']
). in way, aren't violating rule of access control being strict url, allowing server accept multiple different allowed origins.
Comments
Post a Comment