Ask AI is now on the home page — ask a question and get a sourced answer from the Ory docs. You'll also find it in the bottom-right corner of any page.

Skip to main content

Sign in

The sign in flow follows the same pattern as the sign up flow but instead of redirecting to the registration page, it redirects to the login page.

export const registerLoginRoute = (
app,
ory,
baseUrl = process.env.ORY_SDK_URL,
) => {
app.get("/login", (req, res) => {
ory
.toSession({ cookie: req.header("cookie") })
.then((data) => res.json(data))
.catch(() => res.redirect(`${baseUrl}/self-service/login/browser`))
})
}

You can alternatively set return_to to a custom URL. This custom URL must be allow-listed in your project's configuration; otherwise, the request will fail. If allow-listed, this URL will be used as the return URL for the sign in flow:

https://$ORY_SDK_URL/self-service/login/browser?return_to=https://example.com/dashboard