Back to Withastro

Invalid type returned by Astro page.

src/content/docs/en/reference/errors/only-response-can-be-returned.mdx

latest627 B
Original Source

import DontEditWarning from '~/components/DontEditWarning.astro'

<DontEditWarning />

Route returned a RETURNED_VALUE. Only a Response can be returned from Astro files.

What went wrong?

Only instances of Response can be returned inside Astro files.

astro
---
return new Response(null, {
 status: 404,
 statusText: 'Not found'
});

// Alternatively, for redirects, Astro.redirect also returns an instance of Response
return Astro.redirect('/login');
---

See Also: