astro/.changeset/selfish-foxes-bake.md
Bjorn Lu ebd364e392
Add new fields to API route context (#4986)
* Add new fields to API route context

* Add props and redirect

* Pass custom redirect status code

* Correctly pass props in api routes

* Add better docs

* Add test

* Fix build

* Add constants file

* Add links to jsdoc

* Workaround lint issue

* Thanks Chris

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>

* Missed one doc change

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>

* Add more detail to the changesets

* Strict redirect status type

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
2022-10-12 17:03:49 -04:00

14 lines
340 B
Markdown

---
'astro': minor
---
## Support passing a custom status code for Astro.redirect
New in this minor is the ability to pass a status code to `Astro.redirect`. By default it uses `302` but now you can pass another code as the second argument:
```astro
---
// This page was moved
return Astro.redirect('/posts/new-post-name', 301);
---
```