CF appends hashes to my files as well, but I don’t have any issues accessing the site files from a browser.
I’m totally shooting in the dark here, but is there a possibility for a mistake in your scripts? Here are mine (with some redactions to maintain my privacy), which do work. Perhaps you could try replacing yours with these.
wrangler.toml:
account_id = "REDACTED"
name = "REDACTED"
type = "webpack"
zone_id = "REDACTED"
route = "https://www.REDACTED.com/*"
site = { bucket = "./public" }
compatibility_date = "2021-11-27"
I suppose there could be a problem with me creating a new event and not passing in mime type or something. I’ll try and add router at eventhandler to pass the real event.
I posted this on Discord yesterday but not sure you saw so I will re-post here:
The getAssetFromKV should map the asset to the hashed one.
CherryJimbo is best to answer but I can try until he’s around
What I’d recommend first is just passing in the request you’re given rather than making a new one. So, getAssetFromKV({ request: req })
I also see in the docs for kv-asset-handler it’d also like waitUntil (though not sure why exactly) so maybe try to pass that in too.
Then unrelated, your error is trying to get the request from the request. That should just be event.url (the naming for that request is definitely confusing so I’d maybe suggest renaming it too)
I’d suggest doing what I said here and then seeing if you still have issues. If you do, then post your updated code and we can go from there.
I tried replicating request completely and passing request that is heavily modified by framework. The only thing that worked was passing in the entire original event. I nested all assets in public folder inside another one so I can filter out asset calls by the nesting folder name and pathname into separate handler. (Public/assets)