vite site + pages local-dev

I am trying to run vite react site with worker, with local live-reloading dev-server. I set this up:
{
scripts": {
"dev:frontend": "vite",
"dev:backend": "wrangler pages dev --proxy=http://localhost:5173/",
"start": "run-p dev:frontend dev:backend",
"build": "vite build"
}
}
{
scripts": {
"dev:frontend": "vite",
"dev:backend": "wrangler pages dev --proxy=http://localhost:5173/",
"start": "run-p dev:frontend dev:backend",
"build": "vite build"
}
}
So vite runs a local dev-server, then wrangler pages dev proxies pages to it. I hit the wrangler address http://127.0.0.1:8788 and I get an error about no --directory set. I set --directory to public (the static-asset dir for vite) and it 404s on index, but serves other files there. Should I proxy the other way? (hit vite, and proxy for backend to wrangler) Is there a better way to do this?
6 Replies
pkfire
pkfire•14mo ago
helloo - im having a similar problem. Did you ever figure this out? the command im running is wrangler pages dev -- vite ./pages --port 8081 BUT pages functions seem to not work in this scenario
konsumer
konsumerOP•14mo ago
nope, I ended up just working on the front/backend seperately.
pkfire
pkfire•14mo ago
btw i think i got this setup working recently i wish there was just a template command that just init'd all this stuff in a snap
bensua
bensua•6mo ago
hi, what setup did you do for this one?
pkfire
pkfire•6mo ago
Ahh sorry, I don't remember at this point, I changed direction lol. Let me see if I can dig it up from an old project. It was too painful to run this while needing to expand and tweak the config for the life of the project. I also don't think my project was well suited for this.
bensua
bensua•6mo ago
Ah I appreciate it. If you could find the config, it would be great. If you cannot, it is okay. From my understandings, it looks like the --live-reload only live reloads the backend/functions not the frontend 😦 since they using the asset from the dist directory.
Want results from more Discord servers?
Add your server