Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Add non-standard request.cfFetchEvent
Browse files Browse the repository at this point in the history
This allows for use of the waitFor method on the fetch event, which
at present isn't possible (as far as I know) in the standard SvelteKit
API. See sveltejs/kit#2807.
  • Loading branch information
Tom Yandell committed Nov 17, 2021
1 parent c1239a9 commit 01a9286
Show file tree
Hide file tree
Showing 6 changed files with 5,676 additions and 1,409 deletions.
7 changes: 4 additions & 3 deletions entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function handle(event) {
}
}

const response = await renderResponse(request, url)
const response = await renderResponse(request, url, event)
if (response) {
return response
}
Expand Down Expand Up @@ -65,15 +65,16 @@ function notFoundResponse () {
});
}

async function renderResponse(request, url) {
async function renderResponse(request, url, cfFetchEvent) {
try {
const response = await render({
headers: Object.fromEntries(request.headers),
host: url.host,
method: request.method,
path: url.pathname,
query: url.searchParams,
rawBody: request.body ? await read(request) : null
rawBody: request.body ? await read(request) : null,
cfFetchEvent,
})
if (response) {
const headers = new Headers
Expand Down
Loading

0 comments on commit 01a9286

Please sign in to comment.