unsupported URL -- find code

unsupported URL -- find code

shanna9883
Visitor
1 0 0

Hi, all! I'm getting the common error message "Page is redirecting to an unsupported URL". I have the the instructions for how to troubleshoot (below). Where do I update the Javascript code in the Shopify theme? I've gone to "Online Store" -- Theme -- Customize -- Edit Code. I haven't found anything that matches the troubleshooting below. 

 

Troubleshooting Instructions

To resolve this issue, you need to fix the JavaScript code in your Shopify theme. Instead of using “window.location.href =”, you should use “window.parent.location.href =”, or use a reference to the “window.Shopify.designMode” variable in JavaScript.

 

Thanks so much! 

Reply 1 (1)

VipulBudhiraja
Explorer
61 5 7
  1. Search for Redirect Code in JavaScript Files:

    • Go to Online Store > Themes > Actions > Edit Code.
    • In the Assets folder, look for JavaScript files, usually named theme.js, custom.js, or similar. These files are where most JavaScript for your theme is written.
    • Open each file and use Ctrl + F (or Cmd + F on Mac) to search for the term window.location.href =.
  2. Update the Redirect Code:

    • If you find any instances of window.location.href =, replace them with window.parent.location.href = to ensure the redirection works correctly within Shopify’s embedded app environment.
    • Alternatively, you could add a conditional check for window.Shopify.designMode to only run redirection if it’s not in design mode:
      javascript
      Copy code
      if (!window.Shopify.designMode) { window.location.href = 'your-url-here'; // Replace with the URL you want to redirect to }
  3. Check Inline JavaScript in Liquid Files:

    • Sometimes, JavaScript code is included directly in Liquid files. Look in key files like theme.liquid, header.liquid, footer.liquid, and any custom sections (e.g., product-template.liquid).
    • Search for window.location.href in these files, and if found, update it similarly to use window.parent.location.href or add a condition with window.Shopify.designMode.
  4. Save Changes and Test:

    • After making these changes, save your files and refresh your Shopify site to see if the error is resolved. Test in both design mode and preview mode to ensure the fix works in both scenarios.

By following these steps, you should be able to fix the redirection error and ensure proper functioning of redirects within your theme’s code.


Need seamless customer support on your store? Check out the Debales AI Chatbot on Shopify! Guide visitors through every step—let’s chat!

Please let us know if this reply was helpful by giving it a Like or marking it as a Solution.