Category : aws-api-gateway

I was trying to get event.body.data, but it keep return me undefined, i tried JSON.parse(event), JSON.parse(event.body), JSON.parse(event.body.data), JSON.stringify, almost tried out things that i can do with JSON and non of them seems to work. When i tried JSON.parse(event), will give syntax error. So i suspect it already in JSON object format and when i ..

Read more

I have a simple lambda setup in node js with serverless.yml and handler.js. I want to conditionally send different headers as the response to my handler functions. I am using a function called setHeaders to check the origin of the request. If the origin (frontend domain) is as expected, access-control-allow-origin is set as the origin ..

Read more

I am running into a CORS problem which says that I’m unable to load my webpage due to the following: "Access to fetch at ‘ALB Load balancer dns address:port’ from origin ‘ALB Load balancer dns address’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response ..

Read more

I am working on a cdk deploy script and I have it somewhat working but am lost/not having luck setting the different stages and applying different lambdas to the api resources. So I have // Construct lambdas – prod const lambdaBacklogGet = new lambdajs.NodejsFunction(this, "name", { nodeModules: [‘axios’], entry: ‘./src/path/index.js’, handler: ‘handler’, runtime: lambda.Runtime.NODEJS_12_X, timeout: ..

Read more

I have created a serverless express app and deploy it to aws. When I tried to access the endpoint from my front end application. I got the following error: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Here is my express app: app.use((req, res, next) => { res.append(‘Access-Control-Allow-Origin’, ‘*’); res.append(‘Access-Control-Allow-Methods’, ‘GET,PUT,POST,DELETE’); res.append(‘Access-Control-Allow-Headers’, ‘*’); next(); ..

Read more

I have a simple AWS Lambda function as shown below: exports.handler = async function (event, context) { console.log(‘Received event:’, event); context.done(null, JSON.stringify({"status": "success"})); }; it merely logs the event. My main problem is that I am not getting the event body when I use jQuery Ajax to send requests, but I get the event body ..

Read more

I activated CORS on a POST method using the console to allow my resource on https://api.example.com/dev/contact to be called from my website on http://subdomain.example.com. I am using JS Fetch to send the request, but the response is always the same: [Error] Origin http://subdomain.example.com is not allowed by Access-Control-Allow-Origin. [Error] Fetch API cannot load https://api.example.com/dev/contact due ..

Read more