Preflight checklist
Ory Network Project
No response
Describe the bug
I have run into an issue with the ory/nextjs package, specifically the getLoginFlow function:
|
export async function getLoginFlow( |
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:
|
export function guessPotentiallyProxiedOrySdkUrl(options?: { |
In Vercel we have a production and a staging environment. This works fine for our production environment. But in our staging environment the user is sent to the wrong link, e.g. 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 🙏
Reproducing the bug
- Clone this example project https://github.com/ory/elements/tree/main/examples/nextjs-app-router
- Publish to Github
- Link the project in vercel and create a project from main branch.
- GIve the project an additional custom environment called "staging".
- Set the environment variable for each environment
NEXT_PUBLIC_ORY_SDK_URL as any value.
- The login flow will work for production environment but fail for staging environment, with users being directed to
xyz.vercel.app when they initiate a login sequence
Relevant log output
Relevant configuration
Version
1.0.0-rc.0
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response
Preflight checklist
Ory Network Project
No response
Describe the bug
I have run into an issue with the ory/nextjs package, specifically the getLoginFlow function:
elements/packages/nextjs/src/app/login.ts
Line 47 in e159960
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:
elements/packages/elements-react/src/client/config.ts
Line 46 in e159960
In Vercel we have a production and a staging environment. This works fine for our production environment. But in our staging environment the user is sent to the wrong link, e.g.
xyz.vercel.appbecause the logic in this function causes the us to hit this line which sets our sdk url as the incorrect address:But we need the request to be directed to the address we set with this variable, even in staging:
NEXT_PUBLIC_ORY_SDK_URLAlways very grateful for your help and continued support 🙏
Reproducing the bug
NEXT_PUBLIC_ORY_SDK_URLas any value.xyz.vercel.appwhen they initiate a login sequenceRelevant log output
Relevant configuration
Version
1.0.0-rc.0
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response