No CORS headers (e.g. Access-Control-Allow-Origin and Access-Control-Allow-Credentials) are present when invoking a function via aws sdk. Deployed lambda works fine.
Current Behavior
Error in console
Access to XMLHttpRequest at 'http://localhost:4001/2015-03-31/functions/serverless-action-exports-dev-exportTable/invocations' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Bug Report
No CORS headers (e.g. Access-Control-Allow-Origin and Access-Control-Allow-Credentials) are present when invoking a function via aws sdk. Deployed lambda works fine.
Current Behavior Error in console
Access to XMLHttpRequest at 'http://localhost:4001/2015-03-31/functions/serverless-action-exports-dev-exportTable/invocations' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Sample Code
Expected behavior/code
CORS headers are present and no error in console.
Environment
serverless
version: [e.g. v3.30.1]serverless-offline
version: [e.g. v12.0.4]node.js
version: [e.g. v14.21.3]OS
: 13.3.1Possible Solution
Looks like need to handle CORS here https://github.com/dherault/serverless-offline/blob/v12.0.4/src/lambda/HttpServer.js same as here https://github.com/dherault/serverless-offline/blob/v12.0.4/src/events/http/HttpServer.js#L107 Adding onPreResponse fixes the issue for me![](https://i.gyazo.com/0aea0c0fe0d7f042246384d40cecd29d.png)
Additional context/Screenshots