If DEBUG is set to false, the request that fetches the 404 page doesn' honor the options that are set above.
I have changed the following:
let notFoundResponse = await getAssetFromKV(event, {
mapRequestToAsset: req => new Request(`${new URL(req.url).origin}/404.html`, req),
})
...to this:
options.mapRequestToAsset = req =>
new Request(`${new URL(req.url).origin}/404.html`, req)
let notFoundResponse = await getAssetFromKV(event, options)
...which fixed the problem.
If
DEBUGis set to false, the request that fetches the 404 page doesn' honor the options that are set above.I have changed the following:
...to this:
...which fixed the problem.