Skip to content

Commit 3dff5dd

Browse files
committed
PCX review
1 parent a0ce968 commit 3dff5dd

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/content/docs/rules/snippets/examples/follow-redirects.mdx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,30 @@ title: Follow redirects from the origin
1212
description: Modify the fetch request to follow redirects from the origin, ensuring the client receives the final response.
1313
---
1414

15-
```js
15+
```js wrap
1616
export default {
17-
async fetch(request) {
18-
// Define fetch options to follow redirects
19-
const fetchOptions = {
20-
redirect: "follow", // Ensure fetch follows redirects automatically. Remember that each subrequest in a redirect chain counts against subrequest limit.
21-
};
17+
async fetch(request) {
18+
// Define fetch options to follow redirects
19+
const fetchOptions = {
20+
redirect: "follow", // Ensure fetch follows redirects automatically. Each subrequest in a redirect chain counts against the subrequest limit.
21+
};
2222

23-
// Make the fetch request to the origin
24-
const response = await fetch(request, fetchOptions);
23+
// Make the fetch request to the origin
24+
const response = await fetch(request, fetchOptions);
2525

26-
// Log the final URL after redirects (optional, for debugging)
27-
console.log(`Final URL after redirects: ${response.url}`);
26+
// Log the final URL after redirects (optional, for debugging)
27+
console.log(`Final URL after redirects: ${response.url}`);
2828

29-
// Return the final response to the client
30-
return response;
31-
},
29+
// Return the final response to the client
30+
return response;
31+
},
3232
};
3333
```
3434

35-
This template is ready for use and should fit most redirect-following scenarios.
35+
This template is ready for use and should fit most redirect-following scenarios.
3636

37-
It ensures the Snippet transparently follows redirects issued by the origin server.
38-
The `fetch()` API's `redirect: "follow"` option ensures automatic handling of `3xx` redirects, returning the final response. If the origin response is not a redirect, the original content is returned.
37+
It ensures the Snippet transparently follows redirects issued by the origin server. The Fetch API's `redirect: "follow"` option ensures automatic handling of `3xx` redirects, returning the final response. If the origin response is not a redirect, the original content is returned.
3938

40-
**Important**: Snippets have a [maximum number of subrequests per invocation](/rules/snippets/#availability) which depends on your plan. If the origin server issues multiple redirects, each redirect subrequest will count towards this limit. Ensure your origin configuration minimizes unnecessary redirects.
39+
:::note
40+
Snippets have a [maximum number of subrequests per invocation](/rules/snippets/#availability) which depends on your plan. If the origin server issues multiple redirects, each redirect subrequest will count towards this limit. Ensure your origin configuration minimizes unnecessary redirects.
41+
:::

0 commit comments

Comments
 (0)