diff --git a/src/content/docs/en/guides/server-side-rendering.mdx b/src/content/docs/en/guides/server-side-rendering.mdx index 310beecc4568c..0def1086f8a27 100644 --- a/src/content/docs/en/guides/server-side-rendering.mdx +++ b/src/content/docs/en/guides/server-side-rendering.mdx @@ -230,8 +230,10 @@ See more details about [`Astro.cookies` and the `AstroCookie` type](/en/referenc The example below sets a response status and status text for a product listing page when the product does not exist: -```astro title="src/pages/my-product.astro" {8-9} +```astro title="src/pages/product/[id].astro" {10,11} --- +export const prerender = false; // Not needed in 'server' mode + import { getProduct } from '../api'; const product = await getProduct(Astro.params.id); @@ -262,9 +264,9 @@ Astro.response.headers.set('Cache-Control', 'public, max-age=3600'); #### Return a `Response` object -You can also return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object directly from any page using on-demand rendering. +You can also return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object directly from any page using on-demand rendering either manually or with [`Astro.redirect`](/en/reference/api-reference/#astroredirect). -The example below returns a 404 on a dynamic page after looking up an id in the database: +The example below looks up an ID in the database on a dynamic page and either it returns a 404 if the product does not exist, or it redirects the user to another page if the product is no longer available, or it displays the product: ```astro title="src/pages/[id].astro" {10-13, 18} ---