Lambda for extensible redirect / rewrite rules #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@petewilcock this is a very early draft/wip but wanted to run in past you to see what you feel about it.
Use case
As a user when migrating over from an existing website, redirecting links from old page to new pages should be supported.
I thought that the CloudFront Lambda could be exteded to support this use case.
Added a new
lambda_rewrite
to support the existing rules plus custom ones that can be passed on a list onvar.rewrite_rules
.The code for the Lambda is based on this https://github.com/marksteele/edge-rewrite. The repo has been inactive for a few years so i thought that was not worth the work of doing some clever importing.
Done some early basic testing and these 2 scenarios seem to be working:
/
urls to/index.html
/my-old-url
to/shiny-new-url
Potentially this could help with #43 as well, haven't tested that scenario yet but should support host header based matches.
Let me know your thoughts, and sorry for the huge amount of files in the PR, most are the
node_modules
with the dependencies 😞