You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
In my case, I want to send an e-mail on a webhook (which is a POST call from an external service - payment provider for instance).
I store my email template along my static site, so that it is uploaded to the KV store.
I want to retrieve the template using getAssetFromKV, (replacing the request path using mapRequestToAsset), however it fails because the method check is done before this.
I currently have an ugly hack, creating a new pseudo-event with a fresh GET request...
I don't see any drawback to moving this check after the if block (mapRequestToAsset is not supposed to have any side-effect, so calling it before failing should not be a big deal9.
I would be happy to make a PR if you think this is not a bad idea.
The text was updated successfully, but these errors were encountered:
@oliverpool I ran into the same problem and agree with your suggested solution.
For anyone experiencing the same problem, follow @oliverpool's workaround below, it's better than mine because it allows the response to be cached.
asyncfunctiongetResponseFromKV(event,url){letoptions={mapRequestToAsset: req=>newRequest(url),cacheControl: {bypassCache: DEBUG,}}if(event.request.method==='POST'){options.cacheControl.bypassCache=true// Prevents event.waitUntil() from being calledevent={request: newRequest(url)}}returnawaitgetAssetFromKV(event,options)}
Currently in
getAssetFromKV
the HTTP Method is checked before the call tomapRequestToAsset
:kv-asset-handler/src/index.ts
Lines 96 to 111 in 3df430c
I suggest to check the HTTP method after this.
In my case, I want to send an e-mail on a webhook (which is a POST call from an external service - payment provider for instance).
I store my email template along my static site, so that it is uploaded to the KV store.
I want to retrieve the template using
getAssetFromKV
, (replacing the request path usingmapRequestToAsset
), however it fails because the method check is done before this.I currently have an ugly hack, creating a new pseudo-event with a fresh GET request...
I don't see any drawback to moving this check after the
if
block (mapRequestToAsset
is not supposed to have any side-effect, so calling it before failing should not be a big deal9.I would be happy to make a PR if you think this is not a bad idea.
The text was updated successfully, but these errors were encountered: