Switch static site generation to use S3 data instead of API #58
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.
Summary
Resolves static page generation failures by switching from API calls to S3-hosted data during build time. This eliminates rate limiting issues and enables successful generation of 1,862+ package pages.
Problem
Current implementation makes individual API calls for each package during
next build:/api/v1/packages/{name}callsnullresponses → all pages render as 404sSolution
Lambda function pre-fetches all data and uploads to S3. Next.js reads from S3 instead of API:
packages.json,collections.json) → no rate limits → succeedsChanges
Package Pages (
packages/[author]/[...package]/page.tsx)generateStaticParams(): Fetches from${S3_SEO_DATA_URL}/packages.jsongetPackage(): Finds package in S3 JSON array instead of API callgenerateMetadata(): ReusesgetPackage()(eliminates duplicate API call)Collection Pages (
collections/[slug]/page.tsx)generateStaticParams(): Fetches from${S3_SEO_DATA_URL}/collections.jsongetCollection(): Finds collection in S3 JSON array instead of API callgenerateMetadata(): ReusesgetCollection()(eliminates duplicate API call)Configuration
NEXT_PUBLIC_S3_SEO_DATA_URLhttps://prpm-prod-packages.s3.amazonaws.com/seo-dataseo-data/packages.json- Array of all public, non-deprecated packagesseo-data/collections.json- Array of all public collectionsDiff Summary
Deployment Workflow
Lambda invocation (uploads S3 data):
aws lambda invoke \ --function-name prpm-prod-seo-data-fetcher \ --payload '{"bucketName":"prpm-prod-packages","keyPrefix":"seo-data"}' \ response.jsonNext.js build (reads from S3):
Deploy:
npm run deploy # S3 + CloudFrontTesting Plan
s3://prpm-prod-packages/seo-data/packages.jsonnpm run build- should complete without 429 errorsRelated PRs
Rollback Plan
If issues occur:
SKIP_SSG=truein build env (generates only mock pages)🤖 Generated with Claude Code
via Happy