Missing CORS header from the API response body.
I have enabled the Cors in the api as following:
@app.route('/dataset', methods=['POST'], cors=True)
.....
When i deployed the code it adds the OPTIONS object for us but it won't add the Access-Control-Allow-Origin in the response of the POST request, as shown in following image:

The swagger file generated for the cors is following:
{
"post": {
"responses": {
"200": {
"description": "200 response",
"schema": {"$ref": "#/definitions/Empty"}
}
}
}
}
}
While the expected swagger file should be following:
{
"post": {
"responses": {
"200": {
"description": "200 response",
"schema": {"$ref": "#/definitions/Empty"},
"headers": {"Access-Control-Allow-Origin": {"type": "string"}
}
}
}
}
}
The way with how Chalice implements CORS is it will use the proxy integration with API Gateway. So the lambda function that Chalice creates will inject the CORS headers for you into the response that it returns and those headers will simply be proxied to API Gateway. Thus, API Gateway has no models related to the CORS headers because it is just acting as a proxy.
However for OPTIONS, there is no lambda function assigned for it and so it cannot rely on the proxy integration. Instead, Chalice has to rely on API Gateway modeling to include the CORS headers for the OPTIONS method and that is why you see it in the swagger document for the OPTIONS method.
Hopefully that makes sense. Out of curiosity, are you seeing the CORS headers when you make a sample response? They should be there. Or is there a particular reason you want the headers modeled instead of being passed in via the proxy integration?
@kyleknap thanks for explaining i will close the issue.
I was getting Cors error on my UI i have mentioned it over here #670 but it has nothing to do with this i am ignoring the suggested changes.
Thanks.