Search code examples
emailherokuparse-servermailgunheroku-api

mailgun/parse-server(heroku) not working


Having two iOS apps (let us name them appA and appB) both using parse-server hosted on heroku and mailgun, I am facing the problem describe hereafter.

Let me first say that the two apps are unrelated except for the fact they both have user accounts and mail mailgun is used on both to send a confirmation mail when a user creates an account.

appA is working fine, meaning confirmation mail is sent when a new account is created. But appB is no longer working, meaning no confirmation mail is sent when a new account is created.

I have tried to find out what could be the difference between the two, making one work and not the other. I have also read or listened to a few tutorials on the subject, to remind me how I did this kind of settings (back a few months ago). But I can't get hold of any relevant difference and solve my problem, which is to bring appB back to a working state.

Any hint (on what to do or what to look for) by someone with more experience than me in the field would be very much appreciated.

Thanks in advance!

For reference, here is the parse-server index.js for the app which is not working:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var S3Adapter = require('parse-server').S3Adapter;

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://heroku_database',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || '__appId__',
  masterKey: process.env.MASTER_KEY || '__masterKey__',
  filesAdapter: new S3Adapter(
    "__AAKKIII__",
    "pP7Lm16Tt/nTrKq3242Hv",
    "myapp",
    {directAccess: true}
  ),
  serverURL: process.env.SERVER_URL || 'https://myapp.herokuapp.com/parse',
  liveQuery: {
    classNames: ["User", "myappUnit", "myappFieldOne", "myappFieldTwo"]
  },
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      fromAddress: '[email protected]',
      domain: 'mydomain.net',
      apiKey: 'key-fjdfijofd',
    }
  }
});

var app = express();

app.use('/public', express.static(path.join(__dirname, '/public')));

var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

app.get('/', function(req, res) {
  res.status(200).send('I dream of being a website.  Please star the parse-server repo on GitHub!');
});

app.get('/test', function(req, res) {
  res.sendFile(path.join(__dirname, '/public/test.html'));
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

ParseServer.createLiveQueryServer(httpServer);

Solution

  • After searching the net, trying different things and taking a closer look, I ended up by finding what was missing. I put it here in case that may help someone in the future.

    The missing lines in the parse-server index.js in my post are those:

    • verifyUserEmails: true,
    • appName: 'Parse App',

    The lines above need to be included inside:

    var api = new ParseServer({
    ......
    })