Rewrite URLs for an S3 hosted site

0

I'm currently hosting a React site on S3 with CloudFront. One of the URLs used currently looks like this: https://example.org/submit/${token}. As token varies in length, it sometimes means that the total URL can be longer than the S3 limit of 1024. To get around this I'd like to change to a new URL system so that the same route is now located at https://example.org/submit?token=${token} (I assume the query string doesn't count towards the key length limit). This is easy enough to do but I'd like to maintain backwards compatibility with the old route format.

Is there some way that I can rewrite the URL of requests in the old format to be in the new format? It doesn't look like the S3 redirect rules are flexible to allow this, but can it be done in CloudFront instead?

MorayM
feita há 3 meses242 visualizações
3 Respostas
0

If you're using CloudFront and want to transform the request, Lambda@Edge is a great option. [1]

[1] Lambda@Edge example functions - Working with query strings - examples - https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html#lambda-examples-query-string-examples

profile pictureAWS
respondido há 3 meses
0

Take a look at this workshop, shows how to do this with Lambda@Edge and CloudFront Functions.

Handling Rewrites and Redirects using Edge Functions

profile pictureAWS
ESPECIALISTA
kentrad
respondido há 3 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas