XMLHttpRequest failed: \"Unable to connect to the Parse API while file save on cloud code

Hello Team,
I am having this error while run cloud code using JS SDK
code: 100
error: “XMLHttpRequest failed: “Unable to connect to the Parse API””

The same Code run while the server is using HTTP but When I start the server in HTTPS it does not work.
I also try passing {allowInsecureHTTP: true }

Here is Server index.js code ///////////////////////////////////////////////

var FSFilesAdapter = require(’@parse/fs-files-adapter’);

const config = {
filesAdapter: {
module: “@parse/fs-files-adapter”,
databaseURI: databaseUri || ‘mongodb://xxx’,
cloud: process.env.CLOUD_CODE_MAIN || __dirname + ‘/cloud/main.js’,
appId: process.env.APP_ID || ‘xxxx’,
masterKey: process.env.MASTER_KEY || ‘xxx’,
serverURL: process.env.SERVER_URL || ‘https://localhost:1339/parse’,
liveQuery: {
classNames: [‘Posts’, ‘Comments’], // List of classes to support for query subscriptions

var dashboard = new ParseDashboard({
‘apps’: [{
‘serverURL’: ‘https://school.probietech.com/parse’,
‘appId’: ‘xxx’,
‘masterKey’: ‘xx’,
‘appName’: ‘xx’
‘users’: [{
‘user’: ‘xxx’,
‘pass’: ‘xx’,
‘apps’: [{‘appId’: ‘xxx’}]
‘useEncryptedPasswords’: true,

},{ allowInsecureHTTP: true });

const httpsServer = require(‘https’).createServer(cert,app);
httpsServer.listen(port, function () {
console.log('parse-server-example running on port ’ + port + ‘.’);

Here Is a cloud Code //////////////////////////////////////////////////////
Parse.Cloud.define(“importImage”, async (request) => {
const {schoolId,photono,photo} = request.params;
const mainQuery = new Parse.Query(“Students_” + schoolId);
mainQuery.equalTo(“photono”, photono);
let findStudent = await mainQuery.first();
console.log(“findStudent”, JSON.parse(JSON.stringify(findStudent)).objectId)
const studentId = JSON.parse(JSON.stringify(findStudent)).objectId;
const updateEntry = new Parse.Object(“Students_” + schoolId);
if (studentId) {
updateEntry.set(“objectId”, studentId)
if (photo) {
const base64 = photo
const parseFile = new Parse.File(photono,{ base64: base64 });
let newfile = await parseFile.save({ useMasterKey: true })
updateEntry.set(“photo”, newfile);

    return updateEntry.save()
} else {
    throw "There is some issue while updating a record."


If I run same code from client SDK it works again in HTTPs also
Is there any special configuration that I am missing while using this code on server side ?

I believe that your cloud code is trying to access Parse Server via https but Parse Server is not listening https in your localhost. Try with directAccess option set to true.

1 Like