Hello Ory community. I have run into an issue wit...
# ory-selfhosting
l
Hello Ory community. I have run into an issue with the ory/nextjs package, specifically the
getLoginFlow
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:
Copy code
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 🙏
b
are you using the middleware from the next.js package?
l
Yes but not 100% sure I'm using that right. I copied from the example:
export const middleware = createOryMiddleware(config)
where config is:
Copy code
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"],
  },
  },