Workers Vite in browser not trying to reach worker
I'm trying to rebuild my setup to deploy my React SPA together with my api in one worker. For this im using the cloudflare worker vite plugin with
now i have an issue that it always just shows not found on worker paths when accessing them in browser. This is a big issue since I have some /callback routes for auth flows I need the user to be redirected to. Anything I need to configure?
3 Replies
Manage to make it "run" with using
But this will then ofc not work with SPA routing anymore...
I have the same issue. I'm using lucia to for social login in a working Pages app I'm trying to convert to workers with the new Vite plugin. For that we need the browser to be able to hit the worker directly for the login/callback paths but instead just get
Not Found (on root route)
for eg http://localhost:8788/auth/google/log-in
It feels like this would require configuring specific routes that should go to the worker. I found a route
property in wrangler config but that's not what we need. AI thought routing could go in the Vite plugin config but it seems it was just being delusional again. Definitely seems like it should be a wrangler thing as it's directly related to "not_found_handling".
hmm.. https://github.com/cloudflare/workers-sdk/issues/8430#issuecomment-2798510465
I discovered the same thing when setting up OAuth (was very unintuitive). Ended up creating a separate worker to handle it.
I found it is possible to hack a fix into @Cloudflare/vite-plugin..
https://github.com/lecstor/workers-sdk/pull/1
yarn patch @cloudflare/vite-plugin
@cloudflare/vite-plugin/dist/asset-workers/asset-worker.js
GitHub
route auth/* paths to the worker by lecstor · Pull Request #1 · l...
When using the "not_found_handling": "single-page-application" configuration we can't implement OAuth flows that need to hit the worker directly.
This ha...