Hello, when I click the back button under 'sign in...
# general
i
Hello, when I click the back button under 'sign in' from the login screen on prod, it redirects me to localhost:8080. clicking browser back button fixes the URL and next click takes me correctly to the login page. Is this an Ory bug or a misconfiguration on my side? Any idea how I can fix it?
m
you are currently using Ory Tunnel to test/develop locally?
i
no
m
so you are self-hosting Ory Kratos and using Ory Elements for the UI, is that correct?
i
yes
m
This is not a bug, but a common misconfiguration. Update all relevant URLs in your Kratos and Ory Elements configuration to use your production domain instead of
localhost:8080
and the issue should be resolved. For example
Copy code
selfservice:
  default_browser_return_url: <https://your-production-domain.com/dashboard>
  flows:
    login:
      ui_url: <https://your-production-domain.com/login>
      after:
        default_browser_return_url: <https://your-production-domain.com/dashboard>
  allowed_return_urls:
    - <https://your-production-domain.com>
i
Hey @magnificent-energy-493. I tried to apply your suggestion and updated the identity config via the CLI, but the problem still persists in production Here’s what I did:
Copy code
ory patch identity-config \
  --project "$PROJECT_ID" \
  --replace '/selfservice/flows/login/ui_url="<website_url>/auth/login"' \
  --replace '/selfservice/flows/logout/after/default_browser_return_url="<website_url>/auth/login"' \
  --replace '/selfservice/allowed_return_urls=["<ory_api_url>","/ui/logout","/ui/consent","/ui/welcome","/ui/sessions","<website_url>","<website_url>/auth/login","<ory_api_url>/error","<ory_api_url>/login","<ory_api_url>/recovery","<ory_api_url>/settings","<ory_api_url>/registration","<ory_api_url>/verification"]' \
  --format json-pretty \
  > identity-config-$PROJECT_ID-patch-auth-login.json
output says "Project updated successfully!"
and now localhost:3000 redirects to prod url
could you provide a step by step instructions what exacly needs to be updated?
@magnificent-energy-493
m
can you share a link to your production instance and some steps to reproduce for me please?
i
Hey @magnificent-energy-493, to clarify, I realized that a couple of important details may have misled the earlier debugging steps: 1. We are not self-hosting Kratos - we are using the cloud-hosted Ory Network. When I replied “yes, we self-host”, I meant only that we use Ory Elements for the UI, not that Kratos itself is deployed by us. 2. Our application is built with Next.js, not “pure React”, so some behaviors (e.g., router handling, redirects, server vs client boundaries) differ from the examples based on plain React. 3. We also have a custom Yarn patch that overrides part of the behavior in @ory/elements, including redirect logic. Because of this, your suggestion to update the identity config might not have taken effect the way the patch can override the redirect flow, making it impossible to validate the original fix without removing the patch. After updating the identity config, the issue still persisted, so I implemented the change on the frontend • explicit URL generation based on environment - builtUrl() - to ensure all ory uri urls resolve to absolute production URLs • deterministic configuration of
FrontendApi
so the SDK no longer guesses the base path
m
Hey marek, 1. yea I understood that, can you DM me a link to your instance though, then I can check this myself. The Slack here is anonymous so I can't directly tie your email/username to a specific instance on Ory Network. 2. gotcha 3. can you share more info on that custom patch? did you most recent change fix it?
i
You can find more information about the patch in this thread from my colleague @ibeckermayer https://github.com/ory/elements/issues/572#issuecomment-3444199737 My change on the frontend resolved the issue, but I’m not sure if it’s just a workaround rather than a proper fix
👍 1