Skip to content

Add Cloudflare Workers configuration#1

Open
cloudflare-workers-and-pages[bot] wants to merge 2 commits into
mainfrom
cloudflare/workers-autoconfig
Open

Add Cloudflare Workers configuration#1
cloudflare-workers-and-pages[bot] wants to merge 2 commits into
mainfrom
cloudflare/workers-autoconfig

Conversation

@cloudflare-workers-and-pages

@cloudflare-workers-and-pages cloudflare-workers-and-pages Bot commented Jun 13, 2026

Copy link
Copy Markdown

This PR configures your project for Cloudflare Workers deployment using Wrangler autoconfig.

Merging this PR commits the configuration to your repository, enabling faster deployments and version controlled settings.

Detected settings:

  • Framework: astro
  • Build command: npm run build
  • Deploy command: npx wrangler deploy
  • Version (non-production deploy) command: npx wrangler versions upload

Note: For this PR, we used these detected settings to generate a working preview. When merged, we'll override your build and deploy commands if they don't match what's currently configured, ensuring successful deployments for your setup.

Next steps after merging:
Your Worker configuration lives in wrangler.jsonc. You can now:


View build details · Join the discussion for questions or feedback

@sourcery-ai

sourcery-ai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Configures the Astro project to build and deploy on Cloudflare Workers using Wrangler, adding the Cloudflare adapter, Wrangler config and scripts, and ensuring the generated worker types are included in TypeScript.

Flow diagram for new Wrangler-based build and deploy scripts

flowchart TD
  P[npm_run_preview] --> B1[npm_run_build]
  B1 --> WD[wrangler_dev]

  D[npm_run_deploy] --> B2[npm_run_build]
  B2 --> WDEP[wrangler_deploy]

  T[npm_run_cf-typegen] --> WT[wrangler_types]
Loading

File-Level Changes

Change Details Files
Wire Astro app to Cloudflare Workers via adapter and Wrangler config
  • Add @astrojs/cloudflare adapter to Astro config and configure it as the adapter
  • Introduce wrangler.jsonc to define the Cloudflare Workers service configuration (name, routes, build output, env, etc.)
  • Add .assetsignore under public/ to control which static assets are uploaded by Wrangler during deployment
astro.config.mjs
wrangler.jsonc
public/.assetsignore
Update package scripts and dependencies for Cloudflare build/deploy workflows
  • Change preview script to use Wrangler dev after building the Astro app
  • Add deploy and cf-typegen scripts for Wrangler deploy and type generation
  • Add @astrojs/cloudflare runtime dependency
  • Add wrangler as a devDependency and update lockfile accordingly
package.json
package-lock.json
Ensure Cloudflare worker types are included in TypeScript compilation
  • Extend TypeScript include list to cover Cloudflare worker configuration typings
  • Keep existing strict Astro TS base config and dist exclusion
tsconfig.json
Minor repository/config hygiene updates related to Cloudflare setup
  • Adjust .gitignore as needed for Wrangler/Cloudflare artifacts (e.g., .wrangler, build outputs)
.gitignore

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 13, 2026

Copy link
Copy Markdown
Author

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
bmoirdevportfolio f2f44c8 Jun 15 2026, 01:19 AM

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Overriding the preview script to run npm run build && wrangler dev changes its semantics from an Astro preview of the built site to a Cloudflare Worker dev server; consider keeping astro preview (or a separate preview:cf script) so both workflows remain available and clearly distinguished.
  • The site setting in astro.config.mjs is still pointing at the GitHub Pages URL; if this project will now primarily be served via Cloudflare Workers, you may want to update this to the Worker’s final domain to keep canonical URLs and metadata consistent.
  • You’ve pinned @astrojs/cloudflare to the bare major version "12"; if you want to pick up compatible patch/minor updates automatically, consider using a semver range like ^12.0.0 instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Overriding the `preview` script to run `npm run build && wrangler dev` changes its semantics from an Astro preview of the built site to a Cloudflare Worker dev server; consider keeping `astro preview` (or a separate `preview:cf` script) so both workflows remain available and clearly distinguished.
- The `site` setting in `astro.config.mjs` is still pointing at the GitHub Pages URL; if this project will now primarily be served via Cloudflare Workers, you may want to update this to the Worker’s final domain to keep canonical URLs and metadata consistent.
- You’ve pinned `@astrojs/cloudflare` to the bare major version "12"; if you want to pick up compatible patch/minor updates automatically, consider using a semver range like `^12.0.0` instead.

## Individual Comments

### Comment 1
<location path="astro.config.mjs" line_range="16" />
<code_context>
-});
+  },
+
+  adapter: cloudflare()
+});
\ No newline at end of file
</code_context>
<issue_to_address>
**issue (bug_risk):** Cloudflare adapter likely needs matching `output` mode configured to avoid runtime issues.

For `@astrojs/cloudflare` (v12 / Astro 5), the adapter generally expects `output: 'server'` (or `output: 'hybrid'`) in your Astro config. Please add an explicit `output` setting in this config so it matches the Cloudflare adapter’s runtime expectations.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread astro.config.mjs
});
},

adapter: cloudflare()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Cloudflare adapter likely needs matching output mode configured to avoid runtime issues.

For @astrojs/cloudflare (v12 / Astro 5), the adapter generally expects output: 'server' (or output: 'hybrid') in your Astro config. Please add an explicit output setting in this config so it matches the Cloudflare adapter’s runtime expectations.

@cloudflare-workers-and-pages cloudflare-workers-and-pages Bot force-pushed the cloudflare/workers-autoconfig branch 2 times, most recently from 8394086 to 54bf705 Compare June 13, 2026 19:50
@cloudflare-workers-and-pages cloudflare-workers-and-pages Bot force-pushed the cloudflare/workers-autoconfig branch from 54bf705 to 0501172 Compare June 13, 2026 20:03
Signed-off-by: Brian Moir <48401267+bmoir23@users.noreply.github.com>
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