Kind: Interface
Source: packages/core/router/router-response-controller.ts
Part of: Core
RedirectResponse represents the data required to issue an HTTP redirect from the router response controller. It pairs a destination URL with the HTTP status code that determines how clients should handle the redirect, such as 302 for temporary redirects or 301 for permanent redirects.
Properties
| Property | Type |
|---|---|
url | string |
statusCode | number |
Diagram
mermaidgraph LR Router[Router Handler] --> ResponseController[Router Response Controller] ResponseController --> RedirectResponse RedirectResponse --> URL[url: string] RedirectResponse --> Status[statusCode: number] ResponseController --> HTTPRedirect[HTTP Redirect Response]
Usage
tsimport type { RedirectResponse } from './router-response-controller';
const redirectToLogin: RedirectResponse = {
url: '/login?returnUrl=%2Fdashboard',
statusCode: 302,
};
// Pass the redirect response to the router response controller.
responseController.redirect(redirectToLogin);
AI Coding Instructions
- Always provide a valid redirect target in
url; preserve or encode query parameters when building dynamic URLs. - Use an appropriate HTTP redirect status code:
301/308for permanent redirects and302/307for temporary redirects. - Keep redirect construction within routing or response-controller logic rather than returning raw redirect objects from unrelated services.
- Validate or constrain externally supplied redirect URLs to prevent open redirect vulnerabilities.
Was this page helpful?