Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the AWS API Gateway request path case insensitive

It seems that the request path setup in AWS API gateway is case sensitive. Can anyone suggest any solution to make the request path to be case insensitive

For example: https://api-gw.some-domain/health is accessible whereas https://api-gw.some-domain/Health is not accessible. (404)

like image 843
Shaheer Avatar asked Mar 05 '23 02:03

Shaheer


1 Answers

Unfortunately API Gateway, like most of AWS' offerings, is case-sensitive by design.

You therefore have two options:

  • Use CloudFront with Lambda@Edge to re-write your requests (this is quite involved, but a good tutorial can be found here: https://linuxacademy.com/howtoguides/posts/show/topic/19955-url-rewriting-in-aws-cloudfront)

  • Use BasePath mapping and a Proxy Resource so that you can have a single lambda that receives all requests and then dispatches/responds accordingy.

I would recommend the CloudFront approach, as its cheaper and easier to maintain. However for a small API you might be tempted to go for the second, especially if you can host the whole API in a single lambda.

n.b. The internet is case-sensitive (and mostly it's lowercase), for example: http://www.bbc.co.uk/news/world-europe-12083491 vs http://www.bbc.co.uk/news/world-Europe-12083491

like image 55
thomasmichaelwallace Avatar answered May 05 '23 11:05

thomasmichaelwallace