Page is redirecting to an unsupported URL

mh-digital
Shopify Partner
2 0 2
hello, I took over a shop. the shop owner has no problem accessing the customizer but when I try to enter it shows me an error message "Failed to load the page". According to the Shopify community, I have to replace the Theme.js window. location.href = with window.top.location.href I did that but didn't work. In the documentation, it says I have to do this; "to ensure your redirect doesn't interfere with the editor experience, use a reference to the window.Shopify.designMode variable in JavaScript to disable the redirect when you visit the theme editor. This variable is set to true when the storefront is loaded in the editor, and false when it is not." I don't know what to do exactly...
Replies 2 (2)

mh-digital
Shopify Partner
2 0 2

Hey any help with the problem? here is also the code of the theme.liquid file

https://codepen.io/elkocho113/pen/OJBWQdq

eddiearnoldz
Shopify Partner
2 0 1

Had a similar issue just now for a client

Looks like maybe Shopify using the Shopify object so need to guard against it. If in your theme you are declaring a Shopify object then need to add some guard clauses.

We had a file that created our own object and had to add the first few lines

<script>
if (window.Shopify?.designMode) return
if ((typeof window.Shopify) == 'undefined') { window.Shopify = {}; }
Shopify = {
colors: {
...

</script>

From here we could edit in the theme editor as normal