Skip to content

Type Method

redirect(to:type:)

Creates a redirecting Abort error.
static func redirect(to location: String, type: RedirectType) -> Abort

Parameters

location

The path to redirect to

type

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.