-1

I'm using Axios to make a simple GET request to a Shopify store for my client. Here is some of the code used to make the request.

const generateTaggedPosts = async (blog_posts, array) => { 
        await axios.get("{{shop.url}}/admin/api/2022-04/blogs/{{blog.id}}/articles.json", {
          withCredentials: true,
          AccessControlAllowOrigin: '*',
          headers: {
            'Content-Type': 'application/json',
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Credentials': true,
            'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
            'Access-Control-Allow-Headers': 'Content-Type, Authorization'
            }
          })

I've tested this code before on a previous development store and it worked fine. However with this store I recieve a CORS error, stating that no 'Access-Control-Allow-Origin' header is present on the requested resource.

As you can see, I have included this in the header of the request so I'm a bit confused as to why this isn't working.

Any help is much appreciated!

seanrs97
  • 311
  • 2
  • 13
  • The error messages says "on the requested resource" not on the "request". It's a **response** header not a request header. It would be a useless security feature if Site A's JavaScript could tell the browser that Site A was allowed to access data from Site B (with the user's browser, cookies, and IP address). – Quentin May 24 '22 at 10:29

0 Answers0