# How to redirect customers to the previous page instead of the account page with Shopify NCA?

By default, in most of the Shopify themes, customers are redirected to the customer account page right after the login. This creates quite a disruptive experience for the customers during the shopping journey. In this guide, we will help you change this behavior and bring customers back to the right page where they logged in beforehand.

<figure><img src="/files/gCEl1nKL7nA4LnMIVXIz" alt=""><figcaption></figcaption></figure>

### Video

See this video if you want to see it in action:

{% embed url="<https://go.screenpal.com/watch/cTinDdnl2kR>" %}

### Dive into the theme code

Most of the Shopify themes have a `headers.liquid` file, in this file you search for this block of code. And notice the `routes.account_login_url` , this is the variable that is responsible for redirecting the customer post-login. You can change this behavior by updating the [other variables here](https://shopify.dev/docs/api/liquid/objects/routes).

<figure><img src="/files/gyf7NMTL8WSNZl18pNtP" alt=""><figcaption></figcaption></figure>

### Update the code

All you need to do is change the `routes.account_login_url` to `routes.storefront_login_url` , which means it would take customers back to the page before the customer attempted the login.

<figure><img src="/files/fzgzElLzPGxIXzzzRez3" alt=""><figcaption></figcaption></figure>

### Result

As you can see in the result, the customer is redirected back to the cart page with ease and no longer needs to exit the account page, go to checkout anymore. Voila!

<figure><img src="/files/QoCa8q7Ko909YT4bGafR" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.joy.so/how-to-redirect-customers-to-the-previous-page-instead-of-the-account-page-with-shopify-nca.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
