In your Framework. Then when you run the
In your Framework. Then when you run the build command, it builds your Functions for you
12 Replies
SPA->fetch->Functions{kv=islocal?getPlatform:context.env}->response to SPA ?
I already have the context.env in Functions, what's the
getPlatform
use for?
Is that means if I'm not the framework developer, it's no use for me?Wait, so what is your setup? Are you using a framework, or just straight Vite?
I use react+vite+tailwinds to generate SPA. Now I want let it save something. When I use
vite dev
the SPA works ok but the Functions can't work. The Function work depends on the wrangler pages dev
. What if vite
can do this? I found this https://github.com/TorchAuth/vite-plugin-wrangler-spa, but it's not work good.
The final target is use one server that can use bindings local and hot reload from React source file changed.
getPlatformProxy is used by 'who serve the front end'? That means vite should do this but not wrangler?
This plugin allows both the React SPA and Cloudflare functions to run with LiveReload locally, and at the same time.
This solves a major pain point that currently exists, where you cannot work locally with LiveReload for the React project, you are forced to use preview. This plugin allows both the React SPA and Cloudflare functions to run with LiveReload locally, and at the same time.
when use --proxy is a good way that wrangler handle the Functions and vite provide the assets. But that's gone.getPlatformProxy
is really made to be used by your framework, which doesn't help much if you aren't actually using one
Let me see if there is a recommendation for cases like yours...Thanks! https://github.com/TorchAuth/vite-plugin-wrangler-spa is realy fine for me. But there throw an error from wrangler.š
GitHub
GitHub - TorchAuth/vite-plugin-wrangler-spa: Vite plugin that allow...
Vite plugin that allows for simultaneous Cloudflare Page Functions and static SPA development locally - TorchAuth/vite-plugin-wrangler-spa
Ok, got it. Current advice is to run
wrangler pages dev
in one terminal, and vite dev
in the other, then in dev
fetch the pages dev
port for functions callsYes. It sounds good. Will the develop way comes better?š I'm studying remix now. Maybe that's a good way. Thanks for explain!
Actually, the person I was speaking to just passed along this: https://www.npmjs.com/package/wrangler-pages-functions-dev
npm
wrangler-pages-functions-dev
A vite plugin for handling pages functions requests in local dev mode. Latest version: 0.0.7, last published: 3 months ago. Start using wrangler-pages-functions-dev in your project by running
npm i wrangler-pages-functions-dev
. There are no other projects in the npm registry using wrangler-pages-functions-dev.It's not an official thing or anything
But should work as a bodge
That just do what you said. Auto proxy the request redirect to wrangler. I'll try it now. Thanks!
That means some trans the proxy function from wrangler to vite:lul:
wrangler pages dev --proxy [vite_url]
==> vite --prxoy [wrangler_url]
belike :dogekek:
Who's the boss:dogekek:The above package shouldn't need a
--proxy
command?Yes, I'm just making an analogy. It's actruly in vite.config.
To get closer to the truth, he got it from the result after wrangler was executed
This is the essence of this matter.