From 5be0f30a3d2035288d916d73678ccb15d593270c Mon Sep 17 00:00:00 2001 From: Henri Fournier Date: Thu, 23 May 2024 07:29:41 -0700 Subject: [PATCH] Update api-reference.mdx (#8373) Co-authored-by: Sarah Rainsberger --- src/content/docs/en/reference/api-reference.mdx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/content/docs/en/reference/api-reference.mdx b/src/content/docs/en/reference/api-reference.mdx index 231c7b600f318..5b60008487780 100644 --- a/src/content/docs/en/reference/api-reference.mdx +++ b/src/content/docs/en/reference/api-reference.mdx @@ -369,9 +369,13 @@ If true, the cookie is only set on https sites. Allows customizing how the cookie is serialized. ### `Astro.redirect()` -`Astro.redirect()` allows you to redirect to another page. + +Allows you to redirect to another page, and optionally provide an [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) as a second parameter. + A page (and not a child component) must `return` the result of `Astro.redirect()` for the redirect to occur. +The following example redirects a user to a login page, using the default HTTP response status code 302: + ```astro title="src/pages/account.astro" {8} --- import { isLoggedIn } from '../utils';