Skip to content

Commit

Permalink
Review step 1 to add a step for Store Framework stores
Browse files Browse the repository at this point in the history
  • Loading branch information
mariana-caetano committed Jan 30, 2025
1 parent ab6749c commit 7477f0d
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion docs/faststore/docs/go-live/2-integrating-the-vtex-login.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ The VTEX Login is provided by the `vtexcommercestable` environment and uses a su

### Step 1 - Adding a redirect back to your FastStore domain

By the end of this step, changes will be live to all end-users, meaning that once shoppers finish logging in to your store, they will be redirected back to your website's main domain.
By completing this step, shoppers will be redirected back to your website's main domain after logging in or completing a checkout.
The instructions to complete this step depend on where your store's uses My Account and Checkout pages in the [Legacy CMS Portal](#for-legacy-cms-portal-stores) or [Store Framework](#for-store-framework-stores).

#### For Legacy CMS Portal stores

1. Access the VTEX Admin.
2. Go to **Storefront > Layout**.
Expand All @@ -45,6 +48,57 @@ By the end of this step, changes will be live to all end-users, meaning that onc

7. Click on the **Save Template** button.

#### For Store Framework stores

Store Framework stores are built on [VTEX IO](https://developers.vtex.com/docs/guides/vtex-io-documentation-what-is-vtex-io), which has a decoupled architecture where pages like My Account and Checkout are managed as apps. This means these pages are not controlled by the same way as in the Legacy CMS. Instead, they are part of the VTEX IO ecosystem, which requires another approach to handle redirects.

To implement a redirect, you need to create a [Pixel App](https://developers.vtex.com/docs/guides/vtex-io-documentation-pixel-app), which acts as middleware to listen for events (e.g., login or checkout completion) and trigger a redirect to your FastStore main domain.

1. Create a Pixel App by following the [Pixel Apps](https://developers.vtex.com/docs/guides/vtex-io-documentation-1-developnativeintegrationswithpixelapps) track.
2. In the [4. Writing the head and body scripts](https://developers.vtex.com/docs/guides/vtex-io-documentation-5-writingtheheaderandbodyscripts) step, add the following script:

```html
<script>
function redirectToProduction(){
const { pathname, search } = window.location
const redirectDomain = decodeURIComponent("https://www.{addDomainName}.com")
if(
pathname === '/account' ||
pathname === '/login' ||
pathname === '/checkout' ||
pathname === '/checkout/orderPlaced' ||
pathname === '/checkout/orderPlaced/' ||
pathname === '/api/io/account' ||
pathname === '/api/io/login' ||
!redirectDomain) {
return false
}
const redirectLink = redirectDomain + pathname + search
window.location.href = redirectLink
}
(function() {
redirectToProduction()
window.addEventListener('hashchange',() => {
redirectToProduction()
})
})()
</script>
```

> ⚠ Replace https://www.{addDomainName}.com with your store's main domain. For example, if the store's main domain is `https://www.mystore.com`, set the `const` as the following: `const redirectDomain = decodeURIComponent("https://www.mystore.com")`.
3. Complete the remaining steps in the [Pixel app](https://developers.vtex.com/docs/guides/vtex-io-documentation-1-developnativeintegrationswithpixelapps) track to inject the script into your store's login page.

Once completed, shoppers will be redirected to your website's main domain after logging in or completing a checkout.

### Step 2 - Setting the auth cookie root domain

To authenticate client requests and maintain session information, you must ensure that the auth cookies are set up for the **Login** subdomain. To do that, [open a support ticket with VTEX](https://help-tickets.vtex.com/smartlink/sso/login/zendesk) to the Identity team requesting to set up the auth cookie root domain for your FastStore URL.

0 comments on commit 7477f0d

Please sign in to comment.