<@U04UQ68083H> Can I dynamically change the return...
# ory-copilot
q
@chilly-king-10285 Can I dynamically change the return url on sign in or sign up ?
c
A message from kapa.ai
Yes, you can dynamically change the return URL on sign in or sign up. This can be achieved by appending
?return_to=<https://www.myapp.com/blog/write>
when initializing the Login / Registration /Settings flow. For example, if a user requests
<https://www.myapp.com/blog/write>
but isn't logged in, you can redirect the user to that page after login. However, because Ory Identities prevents Open Redirect Attacks, you need to whitelist the domain in your Ory Identities config when using the
?return_to=
query parameter. For other return URLs specified inside the configuration, it isn't necessary to add the domain to the whitelist. Here's an example of how to add a domain to the whitelist:
Copy code
yaml selfservice:     allowed_return_urls:       - <https://www.myapp.com/>
Please note that the return URL can also be set in the configuration for each Self-Service Flow or per method, which will override the default return URL. For example:
Copy code
yaml selfservice:     flows:       login:         after:           default_browser_return_url: <https://end-up-here-after-login/>       registration:         after:           default_browser_return_url: <https://end-up-here-after-registration/>
For more details, please refer to the [Ory documentation](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion#redirection).