I'm using Google AppEngine with PHP7.2 Runtime and i'm facing a problem with CORS.
With GAE standard environment, it is possible to set headers with app.yaml (handlers.http_headers) cf(https://cloud.google.com/appengine/docs/standard/php/config/appref#handlers_element):
handlers:
- url: /images
static_dir: static/images
http_headers:
X-Foo-Header: foo
X-Bar-Header: bar value
With GAE flexible environment, it seems that is not possible:
- No handlers.http_headers variable is usable
- Sets Headers directly in the PHP code does not work:
.
$response->headers->add(
[
'Access-Control-Allow-Origin' => 'http:/blabla-dot-my-app.appspot.com',
'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
]
);
It seems that GAE LB is dropping every header we want to set.
So... how to handle CORS (or other headers) with GAE in flexible environment and PHP7.2 runtime ?