Good day guys.

Good day guys. I wanna ask for advices about how deploy a worker API that I implemented using D1 as storage and a react SPA built using vite, that I used to serve using express.js.
1 - Is it good to deploy the worker as is and in parallel the react SPA in pages? Will this be ok? 2- Will this need cors whitelist or something? 3 -Will be better to serve the SPA using getAssetFromKV from '@Cloudflare/kv-asset-handler'? 4- Will using functions will be better for my case? I'm reading now about Workers Sites, will this be an option?
4 Replies
SteffTek
SteffTek6mo ago
if i read your request the right way, you just askin if you can deploy your api as a worker and host your website as well, right? Worker Pages (or Sites as you call it) can host static html, or a built site from any modern framework, and the worker can host the backend. so yes this is possible, just dont host it from KV :D
SonyC
SonyCOP6mo ago
but how then would I link them to comunicate each other? Like the frontend making request to the api using localhost:8787 or using the dns and whitelisting it on cors options? is there a bindings/service on the toml setting that I can use for it?
SteffTek
SteffTek6mo ago
you can directly call sub workers, the api allows that its like interal http, so just like localhost, but much easier
SonyC
SonyCOP6mo ago
thanks!
Want results from more Discord servers?
Add your server