limited-elephant-93657
09/23/2025, 11:17 AMgetLoginFlow function.
https://github.com/ory/elements/blob/e159960474eb1351bea86afab6d930f41b4acae6/packages/nextjs/src/a…
We call this function when a user navigates to the login page of our site.
Under the hood it uses this function to determine the ory SDK Url:
https://github.com/ory/elements/blob/e159960474eb1351bea86afab6d930f41b4acae6/packages/elements-rea…
In Vercel we have a production and a staging environment. This works fine for our production environment. In our staging environment, the user is sent to the wrong link, i.e. <http://xyz.vercel.app|xyz.vercel.app> because the logic in this function causes the us to hit this line which sets our sdk url as the incorrect address:
if (!isProduction() && process.env.VERCEL_URL) {
return `https://${process.env.VERCEL_URL}`.replace(/\/$/, "")
}
But we need the request to be directed to the address we set with this variable, even in staging: NEXT_PUBLIC_ORY_SDK_URL.
Always very grateful for your help and continued support 🙏bland-eye-99092
09/23/2025, 11:24 AMlimited-elephant-93657
09/23/2025, 11:39 AMexport const middleware = createOryMiddleware(config)
where config is:
export const oryClientConfig: OryClientConfiguration = {
project: {
default_locale: "en",
default_redirect_url: "",
error_ui_url: "",
locale_behavior: "force_default",
name: "",
recovery_enabled: true,
registration_enabled: true,
verification_enabled: true,
registration_ui_url: "/auth/registration",
verification_ui_url: "/auth/verification",
recovery_ui_url: "/auth/recovery",
login_ui_url: "/auth/login",
settings_ui_url: "/settings",
},
sdk: {
url: process.env["NEXT_PUBLIC_ORY_SDK_URL"],
},
},