I am using MeteorJS passwordless authentication, Cloudflare for DNS, Mailgun as an email server, and Nodechef for app hosting: https://docs.meteor.com/packages/accounts-passwordless
Whenever a user submits their email to receive a link in their email inbox to login to the website, the link points to the NodeChef server instead of the domain (i.e. https://example1-12820.nodechef.com instead of https://example.com). Whenever the user logs in via this link, the URL is the NodeChef server as well. I would like for the domain to be in both the link and the URL, mostly for vanity purposes.
For the following assume the correct domain should be example.com:
//body.js
import './body.html';
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Accounts } from 'meteor/accounts-base';
Template.App_body.events({
'submit #login-form'(event) {
event.preventDefault();
const email = event.target.email.value;
if (email == "") {
FlashMessages.sendError("Must enter email to receive link");
} else {
Accounts.requestLoginTokenForUser({
selector: email.toLowerCase().trim(),
userData: { email: email.toLowerCase().trim() }}, function (error) {
if (error) {
FlashMessages.sendError(error);
} else {
FlashMessages.sendSuccess("Check email for login link");
}
});
}
},
});
//fixtures.js
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
Meteor.startup(() => {
process.env.MAIL_URL = Meteor.settings.MAIL_URL;
Accounts.emailTemplates.siteName = 'Example';
Accounts.emailTemplates.from = 'Example Admin <[email protected]>';
Accounts.emailTemplates.sendLoginToken = {
subject() {
return "Login to Example";
},
text(user, url) {
return `Hi there! Login to Example by following this link: ${url}`;
}
};
});
//settings.json
{
"MAIL_URL": "smtp://[email protected]:[email protected]:587"
}
The following are the relevant Cloudflare DNS records of type, key, and value:
CNAME email.mg mailgun.org
CNAME example.com example1-12820.nodechef.com
MX mg mxa.mailgun.org
MX mg mxb.mailgun.org
TXT mg v=spf1 include:mailgun.org ~all
There are other records, but they do not seem to be related.
I have tried changing CNAME and MX records, as well as checking within Mailgun and Cloudflare and NodeChef whether there is a setting that would change the URL sent in the login link to no avail