workers vs pages deployment

it's been a while since i last deployed something to CF pages but at that time CF was on the transition (i think) to merging workers and pages (and that pages will be deprecated at some point?) my question is where should i deploy my react app, it's a purely static react app and the backend is hosted on a VPS (similar to this https://github.com/benawad/how-to-roll-your-own-auth where although the frontend is in nextjs, it doesn't use next's buitin api routes) do i still get the free unlimited api calls and bandwidth even with workers? (as the page doesn't have any server-side functionality at all, just a place to server static HTML, etc assets) thanks!
7 Replies
Kenny
Kenny4w ago
I've seen a lot of frameworks (nextjs 15.3+ and react router v7 for example) stop supporting cloudflare pages and only providing templates for workers so I would assume that workers is the way to go. But with such a simple app I would just do whatever has a solid working example or tutorial backing it to save you time. That's just my two cents from someone who pretty much exclusively uses CF products now so I hope it helps.
rubberburger
rubberburgerOP4w ago
just finished deploying the vite+react app to workers all's good except for the proxy i set up inside vite config any chance you have any idea how to fix this? im using trpc and using vite to proxy to my VPS (works fine locally), but apparently doesn't work when deployed to workers i've also tried installing the cf vite package without the cf vite package, i was just getting 404s with the trpc requests, with the plugin, i get 200s now but no reponses at all (and i doesn't seem like my backend is being hit at all looking at the logs of my VPS) the workers' logs arent working either cos apparently theyre disabled for static-only sites
Kenny
Kenny4w ago
By proxy do you mean do your front end can communicate with your backend or something else? & is your backend rendering your front end html so the user can see it like a full stack app or is this a client request to your backend code?
rubberburger
rubberburgerOP4w ago
yup, the frontend communicating with the backend via trpc as of now i have my backend/vps serving my built frontend as well in addition to the api endpoints but i plan on making the backend just a pure api if i manage to get this to work i only have /api endpoints proxied to the backend btw --------- oh hold on i might have configured trpc incorrectly (this might be for nextjs apps, might have to change to work with my case) kinda found the problem (although there also was trpc being a bit misconfigured) ig it really is the vite proxy because i tried creating a public procedure with trpc and it worked fine so my trpc endpoints/trpc proxy works just fine but my regular non-trpc endpoints (which i use for auth) don't work with vite's proxy for some reason when deployed to cf workers not sure how do debug this but ig one (a bit of a pita tho) would be to rewrite my auth to use trpc instead but yeah a bit of a pita cause the fastify oauth helpers are a bit convenient --- still would be nice if someone know of a way to properly configure vite proxy to work with statically deployed CF worker sites
Kenny
Kenny4w ago
First of all, do console logs not show when you inspect element the page and go to the console? The requests are being sent from the client so your logs should be shown there
Kenny
Kenny4w ago
& if you haven’t come across this yet it could be helpful: https://github.com/orgs/honojs/discussions/4018
GitHub
How to build for React + Vite + Cloudflare worker? · honojs · Dis...
I am using this example provided by Cloudflare for Vite + React + Hono https://github.com/cloudflare/templates/tree/main/vite-react-template which works fine if I use it as-is. But I need to change...
rubberburger
rubberburgerOP4w ago
ill check this out thanks! the browser logs are working just fine by the logs i mentioned earlier, i meant the workers logs, bc i was thinking i might find something there but im not sure it applies to my case cause i don't have any server-side stuff on my workers although it'd be interesting to see the requests to the endpoints themselves tho

Did you find this page helpful?