Bug: guessPotentiallyProxiedOrySdkUrl Returns Wrong SDK Url for Staging (nextJS)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- next.js, typescript
Hướng nghiên cứu
Bắt đầu với packages/elements-react/src/client/config.ts, đặc biệt là guessPotentiallyProxiedOrySdkUrl, và truy vết cách nó được sử dụng từ packages/nextjs/src/app/login.ts. Tái hiện staging deployment được mô tả với examples/nextjs-app-router và kiểm tra cách NEXT_PUBLIC_ORY_SDK_URL và VERCEL_URL được chọn. Hoàn tất khi các luồng đăng nhập trên staging sử dụng SDK URL đã cấu hình, trong khi hành vi trên production vẫn chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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:
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-react/src/client/config.ts#L46
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
- Ngôn ngữ chính
- TypeScript
- Star
- 187
- Fork
- 80
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ory/elements
-
Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
good first issue help wanted upstream
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
-
good first issue help wanted upstream
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
-
Add React-only examplesĐang mởNeeds Triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
-
guessPotentiallyProxiedOrySdkUrl breaks flows in production behind a non-Vercel reverse proxyĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Issue tương tự
-
area/frontend good first issue kind/cooldown
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
voidzero-dev/oxc-angular-compiler#511 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
langchain-ai/deepagentsjs#898 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
anomalyco/models.dev#8509 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug documentation P2 UI/UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày