Page Contents

Home > @loopback/rest > RestApplication > redirect

RestApplication.redirect() method

Register a route redirecting callers to a different URL.

Signature:

redirect(fromPath: string, toPathOrUrl: string, statusCode?: number): Binding;

Parameters

Parameter Type Description

fromPath

string

URL path of the redirect endpoint

toPathOrUrl

string

Location (URL path or full URL) where to redirect to. If your server is configured with a custom basePath, then the base path is prepended to the target location.

statusCode

number

(Optional) HTTP status code to respond with, defaults to 303 (See Other).

Returns:

Binding

Example

app.redirect('/explorer', '/explorer/');