tin-can-api

How to perform Cross Origin request with TinCan.js


I have an LRS set up on scorm cloud, and I'm setting up an LRS object as follows using tincan-min.js:

lrs = new TinCan.LRS(
    {
        endpoint: "https://cloud.scorm.com/tc/xxxxxxxxxx/",
        username: "me@example.com",
        password: "mypassword",
        allowFail: false
    }
);

I can send and retrieve statements from localhost using:

lrs.saveStatement(
    statement, { 
       // error logging
    }); 

However, when I run this in a course, I get a Cross Origin Request failure (because of the Same Origin Policy). I'm not sure what to do to fix this - is there something I can modify when setting up the lrs object or sending the statement?


Solution

  • As Brian pointed out, this functionality is built in and no extra work is needed.