skip to Main Content

I am getting error while sending base64 in ajax request using GET method. I can only use get method as shopify does not allow cross domain with any other method.

GET https://example.com/abc/uploadfile.php?callback=undefined&image=%5B%22data%3Aim

net::ERR_ABORTED 414 (Request-URI Too Long)

Here’s the code:

$.ajax({
    type: "GET",
    data: {
        image: JSON.stringify(dataUrl.match(/.{1,3000}/g))
    },
    crossDomain: true,
    contentType: 'application/json; charset=utf-8',
    url: "example.com/uploadfile.php",
    dataType: "jsonp",
    jsonpCallback: function(data) {
        console.log(data);
        alert("success");
    }
});

2

Answers


  1. If it’s true that:

    1. You have to do this cross-domain; and

    2. Shopify only allows cross-domain ajax requests with GET (not POST); and

    3. Your data is so long that the URI containing is is too long for your browser, their server, or some intermediary;

    then your only option is not to do that. Instead, you might pass the data through a server under your control that will then send it on to Shopify using POST (since the Same Origin Policy is a browser thing).

    Login or Signup to reply.
  2. You will need to use of App Proxy

    With the app proxy you can send request to same domain, regardless weather it is post or get.

    Shopify will automatically redirect your request to your application End Point.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search