logo
Published on

Redirect HTTP to HTTPS in API Gateway

Authors
  • avatar
    Name
    Bowen Y
    Twitter

How to redirect API gateway http to https?

When use API Gateway HTTP API with custom domains(regional), it only works on HTTPS and not on HTTP.

For example, if you have a custom domain like www.example.com, and in your reout53 DNS record you redirect that domain to the involke URL of API gateway, it works fine when a user access you website via https://www.example.com. However, because the api gateway doesn't support http requests, it will raise ERR_CONNECTION_REFUSED error.

So, what should we do if we want to redirect users who enter the URL in the browser search bar manually with http? Cloudfront is one and the only solution according to this link.

Reference:

https://www.reddit.com/r/aws/comments/y30uee/api_gateway_http_to_https_redirection/ https://blog.hyper.io/using-cloudfront-to-redirect-http-to-https-on-apigateway/