1

I've have weird issue, on dev theme (preview mode) $.get request works fine -> https://woolet-co.myshopify.com/blogs/news

but on active theme on main domain https://woolet.co/blogs/news there is an error, I can't figure it out why its happening.

If you try this code in console on both URLs you will see the response code error on main domain:

$.get('/admin/blogs/19692355/articles/229491718.json', function(data) {
      console.log(data);
});

I guess that it's connected with domains, on https://woolet-co.myshopify.com/blogs/news $.get request works fine and on https://woolet.co/blogs/news it shows error in console.

I've tried to execute $.get request through Shopify Private App with login and password included but without any result.

2

2 Answers 2

1

This isn't working for you because your XMLHttpRequest is for a different domain than the one the page is on.

For this to properly work, you need to enable CORS. I would also suggest putting in the absolute URL of where this JSON file is located.

Sign up to request clarification or add additional context in comments.

Comments

1

It would work on your preview mode. Because there both shop url and admin url are on same domain

https://woolet-co.myshopify.com/blogs/news

But when you try to browse using your real domain "https://woolet.co/". The domain from where you are making the get request and the domain from where the file is coming becomes different. ( https://woolet-co.myshopify.com/admin/blogs/19692355/articles/229491718.json )

As far i know you can not enable cors on shopify

and

It wont work because "https://woolet-co.myshopify.com/admin/blogs/19692355/articles/229491718.json" requires you to be logged it to the store as admin.

Try some other way.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.