Skip to content

Type Method

redirect(to:redirectType:)

Creates a redirecting Abort error.
static func redirect(to location: String, redirectType: Redirect = .normal) -> Abort

Parameters

location

The path to redirect to

redirectType

The type of redirect to perform

Return Value

An abort error that provides a redirect to the specified location

Discussion

throw Abort.redirect(to: "https://vapor.codes")

Set type to ‘.permanently’ to allow caching to automatically redirect from browsers. Defaulting to non-permanent to prevent unexpected caching.