Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User stuck in /account page on Deco/Vtex project #846

Open
j-dipierroSocial opened this issue Sep 11, 2024 · 1 comment
Open

User stuck in /account page on Deco/Vtex project #846

j-dipierroSocial opened this issue Sep 11, 2024 · 1 comment
Labels

Comments

@j-dipierroSocial
Copy link
Contributor

Bug Report - User stuck in /account page on Deco/Vtex project

Description

Some of our users are reporting some trouble to be redirected to homepage after using /account and clicking on logo. We already checked if logo had incorrect link in VTEX but it is correct. It happens with every project we do with VTEX and Deco, but we'll use Phytoterápica as an example

Steps to Reproduce (for bugs)

  1. Access https://loja.phytoterapica.com.br
  2. Login
  3. Go to https://loja.phytoterapica.com.br/account
  4. Click on the header logo.

Expected Behavior

It needs to redirect the user to homepage.

Actual Behavior

It will inifinitely load and won't redirect the user to homepage.

Additional Context

This is not a major problem, and doesn't affect the purchase flow, but users are bothered and are asking for a fix.

@guitavano
Copy link
Contributor

guitavano commented Sep 11, 2024

It happens because the navigation of VTEX IO is client-side.

Once I fixed that using a script like:

  addEventListener("pushstate", (e) => {
    e.preventDefault();
    if (e.arguments?.[2]) {
      window.location.href = window.location.origin + e.arguments[2];
    }
  });

it can be used as a loader and inserted on "includeScriptsToHead" prop of proxy.

Loader example:

import { useScriptAsDataURI } from "deco/hooks/useScript.ts";
import { Script } from "apps/website/types.ts";

const snippet = () => {
  addEventListener("pushstate", (e) => {
    e.preventDefault();
    if (e.arguments?.[2]) {
      window.location.href = window.location.origin + e.arguments[2];
    }
  });
};

const loader = (): Script => {
  const transformReq = () => {
    const script = `<script defer src="${
      useScriptAsDataURI(snippet)
    }"></script>`;

    return script;
  };
  return ({ src: transformReq });
};

export default loader;

Not sure how to fix definitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants