Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Bug: guessPotentiallyProxiedOrySdkUrl Returns Wrong SDK Url for Staging (nextJS)

Đang mở
#572 12 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Lĩnh vực
frontend, web-dev

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ả

bug
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:

https://github.com/ory/elements/blob/e159960474eb1351bea86afab6d930f41b4acae6/packages/nextjs/src/app/login.ts#L47

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
  1. Clone this example project https://github.com/ory/elements/tree/main/examples/nextjs-app-router
  2. Publish to Github
  3. Link the project in vercel and create a project from main branch.
  4. GIve the project an additional custom environment called "staging".
  5. Set the environment variable for each environment NEXT_PUBLIC_ORY_SDK_URL as any value.
  6. 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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ory/elements

Tất cả issue của ory/elements

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.