0

I’m trying to return an HTML from a lambda that gets invoked by Kong as a RequestResponse invocation.

This is how the lambda looks like:

exports.handler = function(event, context, callback) {
  context.succeed('<h2>bleh</h2>')
};

This ends up with something like this: enter image description here

Notice the double quotes on the page.

I’ve explicitly set the content type to HTML in response transformer for this lambda invocation. I tried sending a byte array instead, and also switched to using the callback method instead of context.succeed.

How should I go about fixing this?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
bitsapien
  • 1,753
  • 12
  • 24

1 Answers1

1

Using the "is_proxy_integration" configuration that the kong AWS lambda plugin provides helped solved the problem. Check documentation.

This behaves similar to the AWS API gateway integration. Read about it here.

I had to tweak my lambda to return this instead, which made it work:

exports.handler = function(event, context) {
  context.succeed({
    statusCode: 200, 
    headers: {'content-type': 'text/html'}, 
    body: "<h1>bleh</h1>"
  });
};
bitsapien
  • 1,753
  • 12
  • 24