setAsRedirect

fun Response.setAsRedirect(newPath: String, status: Int = 307, isApiPath: Boolean = false)(source)

Set this to a response that tells the client that the requested resource has moved to a new location.

Parameters

status

The specific redirect status code to use. See MDN docs for more information. Defaults to 307 (temporary redirect).

isApiPath

If true, newPath will be prefixed with the "/api" prefix (unless already prefixed). This is useful if you're redirecting the user away from one API endpoint to another. You can of course just prepend "/api" to the path yourself, but in most cases, Kobweb tries to hide the "/api" prefix from the user, so it's a bit strange for us to force them to manually reference it here. Therefore, this parameter is provided as a convenience and as a way to document this situation.