9

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)

Shaheer
  • 155
  • 1
  • 7

2 Answers2

9

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

You therefore have two options:

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

thomasmichaelwallace
  • 7,926
  • 1
  • 27
  • 33
  • thank you for the response. In our setup, the API gateway is already edge optimized with custom domain and cloudfront distribution. So we should create a regional API in this case? Do you have any cloud formation example for the cloudfront with API gateway as origin. Regards, Shaheer – Shaheer Nov 10 '18 at 20:26
  • Hi @thomasmichaelwallace, I setup the CloudFront and Lambda Edge on top of API gateway (regional) and its working basically, and the performance is also excellent. – Shaheer Nov 12 '18 at 15:25
  • Great- if you're all set-up you can mark the answer as the solution so that the next person can find it easily :) – thomasmichaelwallace Nov 12 '18 at 15:36
  • @thomasmichaelwallace I would assume using a greedy {proxy+} as a resource could solve this? The integration destination would handle case insensitive path checking. – Leon Storey Oct 05 '19 at 21:13
  • @leonstorey - interesting take! although because /health is on the base path, it might mean that this lambda has to handle all the API and associated routing. – thomasmichaelwallace Oct 05 '19 at 21:24
2

There's a third and much easier solution to this, but it might perhaps be a little dirty for a production environment. You can add the camelCase and PascalCase variations of your base path, since these are the ones most likely to be used. That's what I've done with my base path for a single API Gateway and it works.

API gateway resources are also case sensitive so the approaches described above are more thorough ways to make your request path case insensitive, since mine only helps with the base path.

Harfel Jaquez
  • 289
  • 4
  • 11