Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API route and rewrites to fetch sitemaps from an S3 bucket #234

Merged
merged 1 commit into from
Feb 10, 2023

Conversation

mbklein
Copy link
Contributor

@mbklein mbklein commented Feb 10, 2023

This PR contains all the changes needed to deliver sitemaps from the root of the server without having to trigger a build every time the sitemap changes.

  • Create a public-read static website bucket to hold sitemaps
  • Create a NextJS api route /api/sitemap/:filename to stream content from the sitemap bucket to the client
  • Add three rewrite rules to the Amplify app to transparently rewrite /sitemap* to /api/sitemap/sitemap* without redirecting the client

Results can be seen in the preview branch at https://preview-sitemap-bucket.d2v1qbdeix3nr2.amplifyapp.com/sitemap.xml

There is a companion PR to tell Meadow about the new sitemap location and have it generate the proper index file

@mbklein mbklein requested a review from adamjarling February 10, 2023 17:04
Copy link
Contributor

@adamjarling adamjarling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. This feels more "right" to me than trying to shoehorn it into a Next page route. Nice work. 👍

@mbklein mbklein merged commit 828a4ef into deploy/staging Feb 10, 2023
@mbklein mbklein deleted the preview/sitemap-bucket branch February 10, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants