# How do I redirect to another URL when using claimCheck?

**URL:** <https://community.auth0.com/t/how-do-i-redirect-to-another-url-when-using-claimcheck/56720>\
**Category:** Get Help\
**Tags:** express, auth0\
**Created:** [January 24, 2021, 11:25pm UTC](https://community.auth0.com/t/how-do-i-redirect-to-another-url-when-using-claimcheck/56720 "2021-01-24T23:25:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackiegleason](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jackiegleason/32/8119_2.png) [@jackiegleason](https://community.auth0.com/u/jackiegleason)\
**Post date:** [January 24, 2021, 11:25pm UTC](https://community.auth0.com/t/how-do-i-redirect-to-another-url-when-using-claimcheck/56720/1 "2021-01-24T23:25:32Z")

</div>

I have the following code…

```
app.get(
    "/secure",
    oidc.claimCheck((req, claims) => {
        console.log(`The roles are ${JSON.stringify(claims)}`);
        return claims["https://secondave.net/roles"].includes("editor");
    }),
    (req, res)=>{
        // TODO: Add a new post
        res.send("Claim worked");
    }
)

```

But in this case I would like to redirect to a specific url (in this case root /) when the user is unauthorized. This way it just redirects back to Auth0 site

---

<div class="post-metadata">

**Author:** ![thameera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thameera/32/13430_2.png) [@thameera](https://community.auth0.com/u/thameera)\
**Post date:** [January 25, 2021, 1:05am UTC](https://community.auth0.com/t/how-do-i-redirect-to-another-url-when-using-claimcheck/56720/2 "2021-01-25T01:05:37Z")

</div>

Hey @jackiegleason, `claimCheck` does not have access to the response middleware, so you cannot redirect from within that. As a workaround, you can manually check the claims and redirect similar to this:

```javascript
app.get(
    "/secure",
    requiresAuth(),
    (req, res)=>{
        if (req.oidc.user["https://secondave.net/roles"].includes("editor")) {
            return res.redirect("/");
        }
        // TODO: Add a new post
        res.send("Claim worked");
    }
)

```

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 25, 2021, 7:38am UTC](https://community.auth0.com/t/how-do-i-redirect-to-another-url-when-using-claimcheck/56720/3 "2021-01-25T07:38:06Z")

</div>

Thanks for sharing that @thameera with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 28, 2021, 3:25pm UTC](https://community.auth0.com/t/how-do-i-redirect-to-another-url-when-using-claimcheck/56720/4 "2021-01-28T15:25:35Z")

</div>


