Skip to content

fix: Rewrite direct s3 urls to point to assets.pubpub.org#3591

Merged
isTravis merged 2 commits intomainfrom
tr/rewrite-s3-urls
Apr 20, 2026
Merged

fix: Rewrite direct s3 urls to point to assets.pubpub.org#3591
isTravis merged 2 commits intomainfrom
tr/rewrite-s3-urls

Conversation

@isTravis
Copy link
Copy Markdown
Member

Some asset URLs in the database use the raw S3 endpoint (https://s3.amazonaws.com/…) instead of the CDN-friendly https://assets.pubpub.org/… form. These bypass our cache, resulting in slower loads and unnecessary S3 egress.

This adds tools/rewriteS3Urls.ts which scans every column known to store asset URLs and rewrites the S3 prefixes in place.

What it rewrites

From To
https://s3.amazonaws.com/assets.pubpub.org/… https://assets.pubpub.org/…
https://s3-external-1.amazonaws.com/assets.pubpub.org/… https://assets.pubpub.org/…

Columns covered

  • TEXT columns: avatars, logos, images across Communities, Pubs, Pages, Collections, Users, Attributions, ExternalPublications, Exports, PubHeaderTheme
  • Freetext/HTML columns: htmlTitle, htmlDescription, heroText, CustomScripts.content
  • JSONB columns: Docs.content, Pubs.downloads, Pages.layout, Collections.layout, ThreadComments.content, Releases.noteContent, ReviewNews.reviewContent, Submissions.abstract, SubmissionWorkflows.*Text, DraftCheckpoints.doc, LandingPageFeatures.payload, ActivityItems.payload, WorkerTasks.input/output

Usage

pnpm run tools rewriteS3Urls            # dry-run — reports counts, changes nothing
pnpm run tools rewriteS3Urls --execute  # rewrites URLs

@isTravis isTravis merged commit 10deb60 into main Apr 20, 2026
2 checks passed
@isTravis isTravis deleted the tr/rewrite-s3-urls branch April 20, 2026 15:57
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.

1 participant