Quantcast
Channel: Active questions tagged aws-lambda - Stack Overflow
Viewing all articles
Browse latest Browse all 3999

HTTPApi + Serverless Framework + API Gateway CORS not working

$
0
0

I have an HTTPApi API Gateway created with the Serverless Framework. But for some routes, the CORS is not working.

provider:  name: aws  runtime: nodejs12.x  stage: dev  region: us-west-2  timeout: 29  httpApi:    cors:      allowedOrigins:        - '*'      allowedMethods:        - GET        - OPTIONS        - POST        - PUT        - DELETE      allowedHeaders:        - Content-Type        - X-Amz-Date        - Authorization        - X-Api-Key        - X-Amz-Security-Token        - X-Amz-User-Agent        - X-Transaction-Key        - Access-Control-Allow-Origin

I tried setting the cors:true option on the provider but still doesnt work.This is the response returned on all routes wether it is 4xx or 2xx codes.

return {    statusCode: StatusCode,    headers: {"Content-Type": "application/json","Access-Control-Allow-Origin": "*","Access-Control-Allow-Credentials" : true,"Access-Control-Allow-Headers" : "*","Access-Control-Allow-Methods": "OPTIONS,POST,GET,PUT,DELETE"    },    body: JSON.stringify(Res, null, 2),  };

If I check the console I can see that the options are indeed appliedHowever, some routes actually work And some others don't, the ones that don't work have the X-Transaction-Key header and the OPTIONS does not return the access-control-allow-headers: authorization,content-type,x-amz-date,x-amz-security-token,x-amz-user-agent,x-api-key,x-transaction-key header

What am I missing?Thanks in advance


Viewing all articles
Browse latest Browse all 3999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>