Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use wrangler-proxy for vite dev scenario #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gerhardcit
Copy link

See issue#1 discussion about Bindings while running wrangler pages dev.

@pirciualex
Copy link

Thank you for the solution, it works well for me. I just have one suggestion: I think it would be a good idea to update the README as well in order to explain how the process of starting the proxy works (and maybe add the command in a script inside package.json).

@gerhardcit
Copy link
Author

I had more luck with cf-bindings-proxy. I've given up on wrangler-proxy

james-elicx/cf-bindings-proxy#43

@clibequilibrium
Copy link

I had more luck with cf-bindings-proxy. I've given up on wrangler-proxy

james-elicx/cf-bindings-proxy#43

hi could you update the PR then ? would be very useful.

Thank you

@dario-piotrowicz
Copy link

@gerhardcit I would suggest you to try the recently introduced Miniflare magic proxy 🙂

It should work quite well with your strategy, you can see how it works here: https://github.com/jculvey/svelte-cf-bindings-poc/blob/master/src/hooks.server.ts

(you basically create a Miniflare instance, take its bindings and simply set those as the platform's env)

@gerhardcit
Copy link
Author

gerhardcit commented Nov 23, 2023

@gerhardcit I would suggest you to try the recently introduced Miniflare magic proxy 🙂

It should work quite well with your strategy, you can see how it works here: https://github.com/jculvey/svelte-cf-bindings-poc/blob/master/src/hooks.server.ts

(you basically create a Miniflare instance, take its bindings and simply set those as the platform's env)

Like this direction. Please advise on how we can get wrangler and Miniflare to use the same locally persisted db path?

jculvey/svelte-cf-bindings-poc#1

I found export declare const DEFAULT_PERSIST_ROOT = ".mf"; in
node_modules/.pnpm/[email protected]/node_modules/miniflare/dist/src/index.d.ts

that must be a option in the Miniflare constructor.

const mf = new Miniflare({
persistRoot: "same as wrangler......"

@dario-piotrowicz
Copy link

@gerhardcit what about the --persist-to flag?
Screenshot 2023-11-23 at 10 17 07

Alternatively if that doesn't work for you how about changing the path miniflare uses by specifing a persistence with different path in the d1Persist option?

-    d1Persist: true,
+    d1Persist: '.wrangler/state/v3/d1',

@dario-piotrowicz
Copy link

that must be a option in the Miniflare constructor.

yes, but it's on a per-storage type basis (this is how I've applied it to our Next.js adapter for example)

@gerhardcit
Copy link
Author

@dario-piotrowicz , thx. d1Persist: '.wrangler/state/v3/d1' does the trick.

This means no need for proxy in dev. This is super helpful!

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.

4 participants