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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • 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!