<@U04UQ68083H> From a selfservice/login native app...
# ory-copilot
f
@chilly-king-10285 From a selfservice/login native app flow, i put the return_to query param when initializing the flow, but i'm redirected to the selfservice.default_browser_return_url setup in the kratos configuration. Do I have to setup something else ?
c
A message from kapa.ai
Yes, there are a few things you need to ensure for the
return_to
query parameter to work correctly: 1. The
return_to
URL should be passed as a query parameter to the endpoint that initializes the flow. For example,
/self-service/{flow_type}/browser?return_to=<https://myapp.com/protected>
([source](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-advanced-integration)). 2. The
return_to
URL is the redirect URL after the flow is completed. If the flow is successful, the user is redirected to the URL defined in the
return_to
parameter ([source](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-advanced-integration)). 3. The
return_to
query parameter doesn't automatically persist across different flows and must be added to new flows. If the user starts a login flow with
return_to
URL set and then switches to a registration flow, the
return_to
URL isn't used for the registration flow ([source](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-advanced-integration)). 4. You need to whitelist the domain in your Ory Identities config when using the
?return_to=
query parameter to prevent Open Redirect Attacks. For example, you can add
<http://myapp.com|myapp.com>
to the whitelist like so:
Copy code
yaml selfservice:    allowed_return_urls:    - <https://www.myapp.com/>
([source](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion)) 5. If you're using Ory Proxy, remember that it adds
/.ory
prefix when mirroring APIs and UIs of Ory Network. So, when using the Ory Proxy, calling
https://<proxy-host>/.ory/ui/login
is the same as calling
https://<your-project-slug>.<http://projects.oryapis.com/ui/login|projects.oryapis.com/ui/login>
directly ([source](https://www.ory.sh/docs/guides/cli/proxy-and-tunnel)). If you've done all of these and it's still not working, it might be a good idea to check your configuration and make sure there are no errors.