Single page application

im developing a SPA , fetching page content from worker after a listen hundler click on the navebar
all page are build like:
function pageHome(env){
return home = some html content ${someData}

now when requesting the page directly from the address bar the page will be served without the index, style…

and as we know for spa,
the server most always serve the index first then the routing in js file take the rest and load the corespondent page …
i know how to do it in httdoc but not in cf worker
sorry for my bad English im not a native speaker.