cloudflare / wrangler-legacy

🤠 Home to Wrangler v1 (deprecated)
https://workers.cloudflare.com
Apache License 2.0
3.2k stars 335 forks source link

[WIP] - RFC: Allow wrangler to use authenticated preview #398

Closed ashleymichal closed 5 years ago

ashleymichal commented 5 years ago

Problem

Note: I am framing this discussion specifically around the KV feature set, but some of this is applicable to other runtime features.

Today Wrangler uses the previewer at cloudflareworkers.com for its wrangler preview command. This allows users to execute their code against an isolated version of the Cloudflare Workers runtime, view console.log output, and do some light debugging of their code in an environment that more closely resembles the runtime on the edge network than, say, a local Node or browser environment.

The same service backs the editor used in the Workers dashboard on dash.cloudflare.com, however, because these users are authenticated, more features are available to them, notably their KV namespaces; by contrast in the unauthenticated editor, KV namespaces are undefined (see #353 ).

Solution

Wrangler should allow users to opt in to running preview in authenticated mode similarly to the way the dashboard does things in order to enhance the debugging experience.

Some complications

385 introduces the idea of multiple environments. One implication of this, especially for KV namespaces, is that a user could specify a different namespace by id for different environments, similar to the way a traditional app might configure a staging database and a production database. This will require that users who have kv namespace bindings configured specify that they do indeed want to run authenticated (as opposed to providing a fallback "mock" value), and in the case that they have multiple environments, specify which environment they want to preview, as calls to their KV store made from inside the Worker are exactly the same as calls made from anywhere else.

Solutions to this include:

EverlastingBugstopper commented 5 years ago

We can close this, right?

ashleymichal commented 5 years ago

yes