Skip to content

Deploy fails with _worker.js error when using Astro base path #15134

@jillesme

Description

@jillesme

Astro Info

Astro                    v5.16.7
Vite                     v6.4.1
Node                     v24.11.1
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  @astrojs/cloudflare (v12.6.12)
Integrations             astro-icon (v1.1.5)

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When deploying to Cloudflare Workers using a base-path, I am presented with:

⛅️ wrangler 4.54.0
───────────────────
▲ [WARNING] Warning: The following routes will attempt to serve Assets on a configured path:

    • my-app.com/garden* (Will match assets: dist/garden*)

  Requests not matching an asset will be forwarded to the Worker's code.


🌀 Building list of assets...
✨ Read 52 files from the assets directory /Users/jilles/Code/small-app-garden/small-app-garden-astro/dist

✘ [ERROR] Uploading a Pages _worker.js directory as an asset.

  This could expose your private server-side code to the public Internet. Is this intended?
  If you do not want to upload this directory, either remove it or add an ".assetsignore" file, to
  the root of your asset directory, containing "_worker.js" to avoid uploading.
  If you do want to upload this directory, you can add an empty ".assetsignore" file, to the root of
  your asset directory, to hide this error.


🪵  Logs were written to "/Users/jilles/.config/.wrangler/logs/wrangler-2026-01-07_02-27-32_113.log"

However, it works fine without a path! I got a workaround by adding a copy step to the build script:

		"build": "astro build && cp public/.assetsignore dist/.assetsignore",

Steps to repreduce:

$ pnpm create cloudflare@latest astro-bug-example
(choose minimal)
(git)
(deploy yes)

Deploys to
https://astro-bug-example.[your acccount].workers.dev

Open up Astro config and set base/path

  site: 'https://astro-bug-example.[your account].workers.dev',
  base: 'example',

Run deploy:

 prerendering static routes
09:41:45 ▶ src/pages/index.astro
09:41:45   └─ /index.html (+5ms)
09:41:45 ✓ Completed in 11ms.

09:41:45 [build] Rearranging server assets...
09:41:45 [build] Server built in 454ms
09:41:45 [build] Complete!

 ⛅️ wrangler 4.57.0
───────────────────
🌀 Building list of assets...
✨ Read 25 files from the assets directory /Users/jilles/Demos/astro-bug-example/dist

✘ [ERROR] Uploading a Pages _worker.js directory as an asset.

  This could expose your private server-side code to the public Internet. Is this intended?
  If you do not want to upload this directory, either remove it or add an ".assetsignore" file, to
  the root of your asset directory, containing "_worker.js" to avoid uploading.
  If you do want to upload this directory, you can add an empty ".assetsignore" file, to the root of
  your asset directory, to hide this error.


🪵  Logs were written to "/Users/jilles/.config/.wrangler/logs/wrangler-2026-01-07_15-41-46_074.log"
 ELIFECYCLE  Command failed with exit code 1.

What's the expected result?

It deploys without error.

Link to Minimal Reproducible Example

https://github.com/jillesme/astro-worker-path-bug-example

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs responseIssue needs response from OP

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions