Skip to content

Cannot access Cloudflare KV variables on platform.env #11149

@socketopp

Description

@socketopp

Describe the bug

I am currently trying to deploy a sveltekit website with Cloudflare workers using Cloudflare KV.
I've followed this guide https://kit.svelte.dev/docs/adapter-cloudflare-workers

I tried building with @sveltejs/adapter-cloudflare:2.3.3 and that works fine, however event?.platform?.env does not contain Cloudflare KV_1.

Reproduction

Here is a minimal reproduction

https://github.com/socketopp/cf-worker-sveltekit-bug

Just clone, insert your Cloudflare details and try it. When logging the event in hooks, it will not display the KV_1 namespace.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (6) x64 Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz
    Memory: 5.76 GB / 15.95 GB
  Binaries:
    Node: 18.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.3636.0), Chromium (119.0.2151.93)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.1
    @sveltejs/adapter-cloudflare: ^2.3.3 => 2.3.3
    @sveltejs/adapter-cloudflare-workers: ^1.2.1 => 1.2.1
    @sveltejs/kit: ^1.27.6 => 1.27.6
    svelte: ^4.0.5 => 4.2.7
    vite: ^4.4.2 => 4.5.0

Severity

annoyance

Additional Information

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