Jump to content
PeakyBlinders

Cross-Domain error when using the API with Ajax

Recommended Posts

Posted (edited) · Cross-Domain error when using the API with Ajax

Hi,

I'm currently trying to use the API to control remotely my Ultimaker 3 with a webpage.

So, I use Ajax to make a request on the printer but it won't allow me to make the request.

For the moment I try to check the validity of the id :

function checkTicket(ticketId) {
            $.ajax({
                    type: 'GET',
                    url: 'http://192.168.1.120/api/v1/auth/check/' + ticketId,
                    contentType: 'application/json',
                    headers: {
                        'Accept': 'application/json'
                    }
                }
            ).done(function (data, textStatus, jqXHR) {
                console.log(data);
                switch (data.message) {
                    case "authorized":
                        break;
                    default:
                        requestTicket(user.name);
                        break;
                }
            }).fail(function (jqXHR, textStatus, errorThrown) {
                console.log(jqXHR);
            });

But I got an error :

Quote

Failed to load http://192.168.1.120/api/v1/auth/check/c6c71b01f5b5292c6261632ae2xxxxxx: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1' is therefore not allowed access.

 

My request headers :

Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.9
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:GET
Cache-Control:no-cache
Connection:keep-alive
DNT:1
Host:192.168.1.120
Origin:http://127.0.0.1
Pragma:no-cache
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36

 

Thanks for your help !

Edited by PeakyBlinders

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Our picks

    • Ultimaker Cura 4.0 | Stable available!
      Ultimaker Cura 4.0 is mainly focused on the improved user interface and cloud integration.
      As always, we want to collect your user feedback for this release. If there are any improvements you can think of, feel free to mention it here and help us to shape the next release.
      • 98 replies
×
×
  • Create New...

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!