Running Express.js + Parse Server and trying to configure HTTPS on the Parse API route with the 'https' JS library.

  • Code snippet

    var https = require('https');
    ....
    https.createServer(config.certificate,app).listen(port,function() {
    console.log('parse-server-example running on port ' + port + '.');
    });
    // This will enable the Live Query real-time server
    ParseServer.createLiveQueryServer(https);
    
  • Steps to recreate

    1. Install the proper libs

      Using: Node (4.5), https (1.0.0)

    2. Run "node index.js"

  • Expected results

    Server should start with no problems running on an HTTPS port https://mydomainhere:4444/parse

  • Actual outcome

    ~/parse/node_modules/parse-server/lib/ParseServer.js:401
    throw err;
    ^
    TypeError: this._server.once is not a function
    at new WebSocketServer (~/parse/node_modules/parse-server/node_modules/ws/lib/WebSocketServer.js:78:18)
    at new ParseWebSocketServer (~/parse/node_modules/parse-server/lib/LiveQuery/ParseWebSocketServer.js:26:13)
    at new ParseLiveQueryServer (~/parse/node_modules/parse-server/lib/LiveQuery/ParseLiveQueryServer.js:103:33)
    at Function.createLiveQueryServer (~/parse/node_modules/parse-server/lib/ParseServer.js:429:14)
    at Object. (~/parse/parse.js:63:13)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    
  • Environment setup

    Using: Node (4.5), https (1.0.0), parse-server ( "2.2.22"), Linux Centos

I had the same problem and reported an issue with parse-server.

Flovilmart helped with that and found out that the right way to do that is to declare a new variable for the https server. In your example you would use:

var https = require('https'); .... var httpsServer = https.createServer(config.certificate,app).listen(port,function() { console.log('parse-server-example running on port ' + port + '.'); }); // This will enable the Live Query real-time server ParseServer.createLiveQueryServer(httpsServer);

you can see the full conversation here: https://github.com/ParsePlatform/parse-server/issues/3165#event-881061654

Although this question was asked long ago, I am trying to answer this question for the future readers as no appropriate answer was posted.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
var fs = require('fs');

var api = new ParseServer({
    databaseURI: 'mongodb://user:pass@localhost:27017/parse', // Connection string for your MongoDB database
    appId: 'your app id',
    masterKey: 'your app master key', // Keep this key secret!
    serverURL: 'https://localhost:1337/parse' // Don't forget to change to https if needed
});

var options = {
    key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem'),
    cert: fs.readFileSync('/etc/letsencrypt/live/example.com/fullchain.pem')
};

// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

var httpsServer = require('https').createServer(options,app);

httpsServer.listen(1337, function() {
    console.log('parse-server-example running on port 1337.');
});
  • Welcome to Serverfault and thanks for this answer! You could make this even more useful by explaining it a little. – Esa Jokinen Aug 13 '17 at 16:32
  • I got error: Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch How to generate certificates? I have .key certificates – Zhanserik Dec 10 at 13:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.