Skip to content

Commit

Permalink
Added context to platform in endpoints with adapter-cloudflare.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-mcfadyen committed Feb 12, 2022
1 parent 8fe3ea3 commit ac35102
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-moles-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-cloudflare': patch
---

Allows access of the context variable on platform inside endpoints. Closes #2807.
5 changes: 3 additions & 2 deletions packages/adapter-cloudflare/files/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export default {
/**
* @param {Request} req
* @param {any} env
* @param {any} context
*/
async fetch(req, env) {
async fetch(req, env, context) {
const url = new URL(req.url);

// static assets
Expand Down Expand Up @@ -49,7 +50,7 @@ export default {

// dynamically-generated pages
try {
return await app.render(req, { platform: { env } });
return await app.render(req, { platform: { env, context } });
} catch (e) {
return new Response('Error rendering route: ' + (e.message || e.toString()), { status: 500 });
}
Expand Down

0 comments on commit ac35102

Please sign in to comment.