1

I have a simple site running on Lambda, using a single proxy resource in API Gateway to route requests to it.

I'm trying to set up some "vanity URLs": someone arriving on /somepath should be redirected to /?source=somepath.

I'm trying to achieve this in API Gateway rather than passing it through to the Lambda app to manage.

  • I've set up a resource on /somepath, with a Mock integration type.
  • The Method Response contains only a 302 type, which contains a Location response header.
  • The Integration Response contains a corresponding 302 response type
  • The Header Mappings contain a Location header mapped to context.resourcePath

This works, sort of. A request to /somepath returns a 302 response with a Location header value of /somepath.

But how can I format that Header Mapping value to be (i.e.):

/?source=${context.resourcePath}

Is there a way I can do this all in API Gateway, using only a Mock endpoint instead of passing the request through to an actual integration backend to return a header value?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.