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

Script Tags not working inside the Shopify iframe but on Localhost #364

Closed
mufftee opened this issue Sep 25, 2023 · 18 comments
Closed

Script Tags not working inside the Shopify iframe but on Localhost #364

mufftee opened this issue Sep 25, 2023 · 18 comments
Assignees

Comments

@mufftee
Copy link

mufftee commented Sep 25, 2023

  • @shopify/shopify-app-remix version: 1.3.0
  • Node version: 20
  • Operating system: MacOSX 13.4.1

Expected behavior

script tags should work inside the iframe in the app/root.jsx

Actual behavior

if you place <script src="//code.tidio.co/c9w65wqt13hznshrcyl9ajlufdctdgxv.js" async={true} /> under <Scripts /> inside the app/root.jsx the script will be loaded, but wont be executed. On the localhost URL from the Shopify app, everything works as expected.

Steps to reproduce the problem

  1. navigate inside app/root.jsx
  2. place <script src="//code.tidio.co/c9w65wqt13hznshrcyl9ajlufdctdgxv.js" async={true} /> under <Scripts />
  3. npm run dev
  4. login to your store
  5. ( if it would work like on localhost ) you should see on the right bottom a blue chat symbol.

Tested this with a fresh template

@mufftee
Copy link
Author

mufftee commented Sep 25, 2023

useEffect(() => {
  const script = document.createElement('script');
  script.src = "//code.tidio.co/c9w65wqt13hznshrcyl9ajlufdctdgxv.js";
  script.async = true;

  document.head.appendChild(script);

  return () => {
    document.head.removeChild(script);
  };
}, []);

also tried already this inside my app/root.jsx both methods just create hydration errors.

@ct-Marvin
Copy link

I can confirm this. Doesn't work with any external script I tested

@ninja-checkout
Copy link

Same issue here, Any Chat or any webwidget is not loading inside shopify admin.

@kticoder
Copy link

Any widget not working in my Shopify app?

@huykon
Copy link

huykon commented Oct 24, 2023

I think that almost chat widget using the iframe to load their chat box so shopify app using the iframe to load app inside admin panel while iframe can't load inside other iframe. That's invalid HTML structure

@lizkenyon
Copy link
Contributor

Also reported here

@huykon
Copy link

huykon commented Nov 2, 2023

@lizkenyon so how to fix this issue?

@lizkenyon
Copy link
Contributor

Hi folks 👋

Thank you to everyone who has flagged this with us. This is something that we will be looking into.

@taitung
Copy link

taitung commented Nov 7, 2023

Hi folks 👋

Thank you to everyone who has flagged this with us. This is something that we will be looking into.

yeah same issue we're facing

@alex-chasm
Copy link

same issue i'm facing here as well

@huykon
Copy link

huykon commented Nov 7, 2023

I can fix this issue by load directly content of widget external url

@lizkenyon
Copy link
Contributor

Hi folks!

We have identified the issue. It looks like when the scripts are added they are executing, but the elements these chat scripts are adding are being overwritten.

The good news is we have a fix for this already that is waiting for release. We are planning on getting this rolled out in the coming weeks.

@lizkenyon lizkenyon self-assigned this Nov 7, 2023
@ninja-checkout
Copy link

@lizkenyon Any news on this?

@lizkenyon
Copy link
Contributor

We hope to start rolling this out next week.

@lizkenyon
Copy link
Contributor

Hi folks 👋

We have a released a change with App Bridge that should allow scripts that update the DOM, (like adding iframes for chat widgets) to work.

Please test out adding your scripts and see if they now work. 🙂

@ninja-checkout
Copy link

Thanks @lizkenyon

Works like charm

@huykon
Copy link

huykon commented Dec 12, 2023

@lizkenyon which is the latest version?

@lizkenyon
Copy link
Contributor

It should be working automatically. You will not need to upgrade any package.

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

No branches or pull requests

8 participants