Jump to content
Ultimaker Community of 3D Printing Experts
PeakyBlinders

Cross-Domain error when using the API with Ajax

Recommended Posts

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

  • Our picks

    • How to 3D print with reinforced engineering materials
      Ultimaker is hosting a webinar where we explain how you can achieve and maintain a high print success rate using these new reinforced engineering materials. Learn from Ultimaker's Product Manager of Materials and top chemical engineer Bart van As how you can take your 3D printing to that next level.
      • 0 replies
    • "Back To The Future" using Generative Design & Investment Casting
      Designing for light-weight parts is becoming more important, and I’m a firm believer in the need to produce lighter weight, less over-engineered parts for the future. This is for sustainability reasons because we need to be using less raw materials and, in things like transportation, it impacts the energy usage of the product during it’s service life.
        • Like
      • 12 replies
×

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!