-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pages: Fix "worker called response.clone()" warnings in `wrangler pag…
…es dev` Fixes #3259
- Loading branch information
1 parent
fbd2a4c
commit 0faa6f8
Showing
9 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
fixtures/pages-functions-with-routes-app/functions/api/greet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export async function onRequestPost(context) { | ||
try { | ||
let data = await context.request.json(); | ||
return new Response(`[/functions/api/greet]: ${data.greeting}`); | ||
} catch (err) { | ||
return new Response("Error parsing JSON content", { status: 400 }); | ||
} | ||
} |
14 changes: 12 additions & 2 deletions
14
fixtures/pages-functions-with-routes-app/functions/greeting/hello.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
export async function onRequest() { | ||
return new Response("[/functions/greeting/hello]: Bonjour le monde!"); | ||
export async function onRequest(context) { | ||
const url = new URL(context.request.url); | ||
|
||
const response = await fetch(`${url.origin}/api/greet`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ greeting: "Bonjour le monde!" }), | ||
}); | ||
|
||
return new Response(`[/functions/greeting/hello]: ${await response.text()}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"include": ["/", "/greeting/*", "/greeting*", "/date"], | ||
"include": ["/", "/greeting/*", "/greeting*", "/date", "/api/*"], | ||
"exclude": ["/bye*", "/date", "/*.*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"include": ["/greeting/*", "/date", "/party*"], | ||
"include": ["/greeting/*", "/date", "/party*", "/api/*"], | ||
"exclude": ["/", "/party"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters