Global CORS AllowCredentials: true not setting header
Description:
I'm getting the following error even though I have applied the AllowCredentials: "true" setting to my config:
Access to XMLHttpRequest at 'http://localhost:3000/auth/token' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Steps to reproduce the issue:
Globals:
Api:
Cors:
AllowOrigin: "http://localhost:8080"
AllowHeaders: "*"
AllowCredentials: "true"
Observed result:
Changing AllowHeaders is reflected in the response to my request.


Expected result:
No CORS Error :-D
@peregrinius Could you try by removing the quotes for AllowCredentials: true. AllowCredentials expects a boolean value
Template:
Globals:
Api:
Cors:
AllowOrigin: "http://localhost:8080"
AllowHeaders: "*"
AllowCredentials: true
Thanks for your reply Shreya. I tried that but still the same error :-(
Hi @peregrinius! It also looks like Cors expects quoted strings:
Globals:
Api:
Cors:
AllowOrigin: "'http://localhost:8080'"
AllowHeaders: "'*'"
AllowCredentials: true
https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#cors-configuration
Hi @keetonian I think the documentation is out of date. They recently released an update to remove the need for putting both single and double quotes.
I removed the { withCredentials: true } from my axios request and it works now 🤷♂