Skip to content

Migrate to Cloudflare workers#1311

Merged
eyeseast merged 50 commits intomainfrom
cloudflare-workers
Apr 13, 2026
Merged

Migrate to Cloudflare workers#1311
eyeseast merged 50 commits intomainfrom
cloudflare-workers

Conversation

@eyeseast
Copy link
Copy Markdown
Collaborator

@eyeseast eyeseast commented Mar 31, 2026

This moves us off Netlify and sets up deployments using Cloudflare Workers. It creates three distinct and separated environments:

  • previews
  • staging
  • production

Each one gets its own Wrangler file. Staging and production are static configs, previews are generated for each PR.

File Worker Name Domain Deployed by
wrangler.production.jsonc documentcloud-frontend www.documentcloud.org Workers Builds (from main)
wrangler.staging.jsonc documentcloud-frontend-staging staging.documentcloud.org Workers Builds (from main)
wrangler.preview.jsonc dc-preview-<PR#> preview-<PR#>.staging.documentcloud.org GitHub Actions (generated at CI time, not checked in)

This gives us a staging staging server for other services to use (#1286) and gives us previews like we have on Netlify.

One thing to note here: We're creating a new worker for each PR, and deleting it when we close/merge the PR. If we need to look at an old branch, we can reopen the PR.

Deployment

When we deploy this, we should:

  1. Merge this PR
  2. Delete the current DNS record for www.documentcloud.org, pointing to Netlify
  3. Add a custom domain to the documentcloud-frontend worker for www.documentcloud.org

At that point, we'll be live on Cloudflare.

Closes #1286
Closes #1235
Closes #1257

Separately, we need to make sure these redirects are covered, either as SvelteKit routes or through the CF control panel:

# we don't have any of these
/.well-known/* /404.html 404
/ads.txt /404.html 404

# sometimes asset paths get mislaid
/documents/_app/* /_app/:splat
/documents/:id/_app/* /_app/:splat

# old URLs
/search/ /documents/
/app /documents/
/api/oembed.json https://api.www.documentcloud.org/api/oembed/

@cloudflare-workers-and-pages

This comment was marked as outdated.

@eyeseast eyeseast force-pushed the cloudflare-workers branch from f75c6ed to db45fce Compare April 1, 2026 12:34
@eyeseast eyeseast changed the base branch from 1233-svelte-5-common to main April 1, 2026 12:34
@netlify

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 58.63% 2380 / 4059
🔵 Statements 59.23% 2756 / 4653
🔵 Functions 60.58% 621 / 1025
🔵 Branches 59.34% 1460 / 2460
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/api/addons.ts 70% 69.64% 61.11% 70% 82-187, 369-375
src/lib/api/types.d.ts 0% 0% 0% 0%
src/lib/components/addons/AddOnListItem.svelte 100% 50% 100% 100%
src/lib/components/addons/AddOnPin.svelte 0% 0% 0% 0%
src/lib/components/addons/AddOnsNavigation.svelte 100% 100% 100% 100%
src/lib/components/addons/History.svelte 0% 0% 0% 0%
src/lib/components/addons/Scheduled.svelte 0% 100% 0% 0% 83-94
src/lib/components/addons/ScheduledEvent.svelte 0% 100% 100% 0% 62
src/lib/components/addons/Selection.svelte 91.66% 50% 100% 85.71% 66, 81
src/lib/components/documents/ResultsList.svelte 95.23% 66.66% 100% 94.44% 199
src/lib/components/forms/AddOnDispatch.svelte 0% 100% 100% 0% 235-330
src/lib/components/forms/Search.svelte 0% 0% 0% 0%
src/lib/components/forms/Share.svelte 61.84% 57.14% 61.11% 60.34% 152-170, 151-167, 211, 223, 232, 244, 256, 278-281
src/lib/components/layouts/AddOnLayout.svelte 0% 0% 0% 0% 192-247
src/lib/components/sidebar/SidebarGroup.svelte 0% 0% 0% 0%
src/lib/components/sidebar/tests/Documents.demo.svelte 0% 0% 0% 0%
src/lib/components/storybook/ContextDecorator.svelte 0% 0% 0% 0%
src/lib/components/viewer/AnnotationLayer.svelte 0% 100% 0% 0% 224-253
src/lib/components/viewer/RedactionLayer.svelte 0% 0% 0% 0%
Generated in workflow #1187 for commit a6a3a13 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

Preview deployed: https://preview-1311.staging.documentcloud.org

@duckduckgrayduck
Copy link
Copy Markdown
Contributor

The frontend staging URL: https://staging.documentcloud.org/home/
When I click login it directs me to production. The hover over link also says api.www.documentcloud.org/accounts/logi..

The deploy preview appears correctly routed and is working for me. It appears sometimes the redirect back to the deploy preview times out, but refreshing the page gets me logged in anyways.

@duckduckgrayduck
Copy link
Copy Markdown
Contributor

Pinning & unpinning an Add-On seems to have broken

@duckduckgrayduck
Copy link
Copy Markdown
Contributor

duckduckgrayduck commented Apr 7, 2026

When I click to dispatch an Add-On it seems to freeze the top navigation bar, the notification doesn't appear (until a refresh) and I'm unable to use any of the other dropdowns.

If I have the "Explore Add-Ons" menu open and click to open an Add-On, the URL changes, but the Add-On doesn't open until a refresh

@duckduckgrayduck
Copy link
Copy Markdown
Contributor

duckduckgrayduck commented Apr 7, 2026

The Scraper & Klaxon Add-Ons, I presume because they don't have any documents needed in their context, open in full page view instead of with the current search. We should probably default to side panel view always to make it a consistent user experience and not have to have two possible paths. For the Scraper Add-On it asks us to put in a project ID too, so we would likely grab that from the search context

@eyeseast
Copy link
Copy Markdown
Collaborator Author

eyeseast commented Apr 7, 2026

The staging url https://staging.documentcloud.org/home/ is an old build. It'll update when we merge this into main.

This is the url to test: https://preview-1311.staging.documentcloud.org/

@duckduckgrayduck
Copy link
Copy Markdown
Contributor

The staging url https://staging.documentcloud.org/home/ is an old build. It'll update when we merge this into main.

This is the url to test: https://preview-1311.staging.documentcloud.org/

Yea, all the further testing was on the deploy preview

@eyeseast
Copy link
Copy Markdown
Collaborator Author

eyeseast commented Apr 7, 2026

Add-On issues should be fixed now. There was an infinite loop happening in the <History> component.

Copy link
Copy Markdown
Member

@mitchelljkotler mitchelljkotler left a comment

Choose a reason for hiding this comment

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

Just want to confirm that the redirects from _redirects were implemented outside of code in Cloudflare config?

@eyeseast
Copy link
Copy Markdown
Collaborator Author

eyeseast commented Apr 8, 2026

Just want to confirm that the redirects from _redirects were implemented outside of code in Cloudflare config?

Yes. I'll add that to the deployment plan. There's no equivalent of that file in Cloudflare, so we either need to implement them in the control panel or as SvelteKit routes. Probably better to consolidate approaches anyway.

@allanlasser
Copy link
Copy Markdown
Member

I would I'd prefer to have redirects saved into the codebase. Better accountability, easier to reference, and coupled to code changes that require them.

Comment thread plans/preview-deploy.md Outdated
@@ -0,0 +1,55 @@
# Cloudflare Workers Deployment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Delete before merging?

@duckduckgrayduck
Copy link
Copy Markdown
Contributor

The Scraper & Klaxon Add-Ons, I presume because they don't have any documents needed in their context, open in full page view instead of with the current search. We should probably default to side panel view always to make it a consistent user experience and not have to have two possible paths. For the Scraper Add-On it asks us to put in a project ID too, so we would likely grab that from the search context

Still noticing this, but all other Add-Ons issues are fixed

@eyeseast
Copy link
Copy Markdown
Collaborator Author

eyeseast commented Apr 9, 2026

The Scraper & Klaxon Add-Ons, I presume because they don't have any documents needed in their context, open in full page view instead of with the current search. We should probably default to side panel view always to make it a consistent user experience and not have to have two possible paths. For the Scraper Add-On it asks us to put in a project ID too, so we would likely grab that from the search context

That's how they look in production: https://www.documentcloud.org/add-ons/MuckRock/documentcloud-scraper-addon/.

We don't show the document search for Add-Ons that don't run on Documents. It's not related to this PR.

Comment thread src/config/config.js
Comment thread vite.config.js Outdated
Comment thread package.json Outdated
@allanlasser
Copy link
Copy Markdown
Member

Aside from the remote stuff, everything else is working well for me.

Copy link
Copy Markdown
Member

@allanlasser allanlasser left a comment

Choose a reason for hiding this comment

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

Everything looks good to me!

@eyeseast eyeseast marked this pull request as ready for review April 13, 2026 14:04
@eyeseast eyeseast merged commit 509ac54 into main Apr 13, 2026
12 of 13 checks passed
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.

Create static staging site for testing integrations Remove instances of "bubble" Migrate Add-Ons components to Svelte 5 syntax

4 participants