Skip to content

Commit

Permalink
Update api-reference.mdx (#8373)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
hfournier and sarah11918 committed May 23, 2024
1 parent add88b2 commit 5be0f30
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/content/docs/en/reference/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 5be0f30

Please sign in to comment.