# Redirect After Login

**URL:** <https://forums.losant.com/t/redirect-after-login/5566>\
**Category:** Help\
**Tags:** dashboard, workflow, cpf\
**Created:** [August 14, 2024, 8:36pm UTC](https://forums.losant.com/t/redirect-after-login/5566 "2024-08-14T20:36:25Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [March 19, 2025, 6:06pm UTC](https://forums.losant.com/t/redirect-after-login/5566/21 "2025-03-19T18:06:08Z")

</div>

Hi @Brandon_Cannaday coming back to this a while later, is there a easier/more dynamic way to allow the login to redirect to any page after login in completion with out having to put the

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/e44507cf7a7c94f77d54fb56730711c9ab32dcc5.png)  
redirect path explicitly in each pages redirect path.  
Id like it to work out right to any page, after you long in, but having to remember to put the redirect in each new pages sounds like an easy way to have mistakes.

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [March 19, 2025, 6:23pm UTC](https://forums.losant.com/t/redirect-after-login/5566/22 "2025-03-19T18:23:28Z")

</div>

Experiences do support version-wide unauthorized handlers:

> **[Experience Versions](https://docs.losant.com/experiences/versions/#unauthorized-replies)**
>
> Learn more about creating and using experience versions in the Losant platform.

You can find this by clicking the `Edit` main navigation menu → the three dots in the top-right corner → Version Settings.

You can provide a template there that sends the user to `/login` and appends the user’s current page and query parameters to a `redirect` parameter.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/7acdb2dfab519c5728b55061657b9112b8c288bb.png)

The template is:

```auto
/login?redirect={{encodeURIComponent request.path}}%3F{{encodeURIComponent (queryStringEncode request.query)}}

```

Then, you can configure each endpoint to use the **Version’s default “Unauthorized” reply** :

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/e2aa81f47af51e7bfbd2386c31e322a917c55905.png)

To summarize:

1. Configure the default unauthorized behavior that can be applied to every endpoint in your experience.
2. Update all existing endpoints to use the new default behavior.
3. All new endpoints automatically use the version default, so you’ll never have to remember to add this behavior in the future.

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [March 19, 2025, 6:43pm UTC](https://forums.losant.com/t/redirect-after-login/5566/23 "2025-03-19T18:43:40Z")

</div>

Great! I will have to manually set each endpoints redirect to use default? is there a way to make sure this is always the default for new endpoints

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [March 19, 2025, 6:47pm UTC](https://forums.losant.com/t/redirect-after-login/5566/24 "2025-03-19T18:47:01Z")

</div>

You’ll have to update your existing endpoints. There’s nothing you have to do for new endpoints. Using the version-wide unauthorized handler is the default setting for new endpoints.

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [March 19, 2025, 7:17pm UTC](https://forums.losant.com/t/redirect-after-login/5566/25 "2025-03-19T19:17:13Z")

</div>

Probably spent more time building this trying to figure out how to escape {{ }} in a string than it would’ve took to do it manually but, I was able to mass update every endpoint via this setup using the API node.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/00fdc95225380dd11df13cd6635653a35262820c.png)  
Then loop over the resulting endpoints using their id  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/6/6b962b8e066af9b1482cc8ac1fff92b8f598f68c.png)

and use this json as the patch

```auto
{
    "unauthorizedReply": {
        "type": "redirect",
        "value": "/login?redirect=\u007B\u007BencodeURIComponent request.path\u007D\u007D%3F\u007B\u007BencodeURIComponent (queryStringEncode request.query)\u007D\u007D"
    }
}

```

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [March 19, 2025, 7:30pm UTC](https://forums.losant.com/t/redirect-after-login/5566/26 "2025-03-19T19:30:25Z")

</div>

To escape curly braces in templates, you use a leading backslash:

```auto
{
  "path": "/devices/\{{hello}}"
}

```

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/2117c966f337271b16568e155703d84c6a2b071b.png)

However, what you’re doing is updating every endpoint to have its own redirect configuration. If you want to use the version default, you need instead set `unauthorizedReply` to `null`:

```auto
{
  "unauthorizedReply": null
}

```

That will remove the endpoint-specific behavior, which causes it to fall back to the version default behavior.

[Previous page](https://forums.losant.com/t/redirect-after-login/5566.md?page=1)
