-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
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
| 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_URLas any value. - The login flow will work for production environment but fail for staging environment, with users being directed to
xyz.vercel.appwhen 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