Skip to content

.assetsignore support on adding adapter-cloudflare to  #13108

@methanoya

Description

@methanoya

Describe the bug

There is an inconsistency in the deployment of Cloudflare worker if project is done without using cloudflare@latest script. If we just add @sveltejs/adapter-cloudflare it can have errors like:

$ npm run deploy

> [email protected] deploy
> wrangler deploy


 ⛅️ wrangler 3.92.0
-------------------

🌀 Building list of assets...

✘ [ERROR] Uploading a Pages _worker.js file 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 file, 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 file, you can add an empty ".assetsignore" file, to the root of your
  asset directory, to hide this error.

The reason for this error is missing the .assetsignore file on .svelte-kit/cloudflare path. The .assetsignore tells that files like _worker.js, _routes.json, _headers, and _redirects are not assets and must not be exposed. See cloudflare/workers-sdk#6640 for details.

Workaround is adding https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/templates-experimental/svelte/js/static/.assetsignore to static folder of the project. I am going to issue a PR to fix this.

Reproduction

Try to make some UI library based app ((Skeleton, for example) and enable Cloudflare deployment. Follow instructions from:

The deployment script would look like

  "scripts": {
    "deploy": "wrangler deploy",

Error is: ✘ [ERROR] Uploading a Pages _worker.js file as an asset.

Logs

No response

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
    Memory: 6.25 GB / 31.17 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.11.0 - /usr/bin/node
    npm: 10.9.1 - /usr/bin/npm
    pnpm: 9.14.4 - /usr/bin/pnpm
  Browsers:
    Brave Browser: 131.1.73.91
    Chrome: 130.0.6723.116
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.3.1 
    @sveltejs/adapter-cloudflare: file:../../../sveltekit/packages/adapter-cloudflare => 4.8.0 
    @sveltejs/kit: ^2.0.0 => 2.9.0 
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.1.2 
    svelte: ^4.2.7 => 4.2.19 
    vite: ^5.0.3 => 5.4.11

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions