I have migrated data from the parse website to Azure's version of parse and notice some components were missing like an email adapter. So I follow the instructions from here https://www.npmjs.com/package/parse-server-postmark-adapter. I'm able to receive email to change my password.
But I get this error when I click on the link to change my password,
"level":"error","message":"Uncaught internal server error. [Error: Can't set headers after they are sent.]
Can anyone explain why I'm getting this message? Also, I put the code to configure postmark in my config.js file.
Edit:
var PostmarkAdapter = require('parse-server-postmark-adapter');
module.exports = {
server: {
appName: 'myapp',
publicServerURL: 'http://myapp.azurewebsites.net/parse',
verifyUserEmails: true, // Enable email verification
emailAdapter: PostmarkAdapter({
apiKey: 'api-key-0000',
fromAddress: 'someemail#email.com',
})
},
dashboard: {},
storage: {},
push: {}
}
Related
I'm trying to run a nodemailer service within an azure function app and it keeps throwing AUTH error. Here's my code below :
require("dotenv").config();
const nodemailer = require("nodemailer");
const getMailIDs = require("./getMailIDs");
module.exports = async function mailSender() {
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
service: "gmail",
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD,
},
});
let mailIDs = await getMailIDs();
for (i = 0; i < mailIDs.length; i++) {
await transporter.sendMail({
from: "abc#gmail.com",
to: `${mailIDs[i]}`,
subject: "Test Mail",
text: {
path: `emailBody.txt`,
},
});
}
};
This is the error thrown :
Error: Missing credentials for "PLAIN"
at SMTPConnection._formatError (C:\Projects\azure\node_modules\nodemailer\lib\smtp-connection\index.js:784:19)
at SMTPConnection.login (C:\Projects\azure\node_modules\nodemailer\lib\smtp-connection\index.js:438:38)
at C:\Projects\azure\node_modules\nodemailer\lib\smtp-transport\index.js:271:32
at SMTPConnection.<anonymous> (C:\Projects\azure\node_modules\nodemailer\lib\smtp-connection\index.js:209:17)
at Object.onceWrapper (events.js:299:28)
at SMTPConnection.emit (events.js:210:5)
at SMTPConnection._actionEHLO (C:\Projects\azure\node_modules\nodemailer\lib\smtp-connection\index.js:1319:14)
at SMTPConnection._processResponse (C:\Projects\azure\node_modules\nodemailer\lib\smtp-connection\index.js:947:20)
at SMTPConnection._onData (C:\Projects\azure\node_modules\nodemailer\lib\smtp-connection\index.js:749:14)
at TLSSocket.SMTPConnection._onSocketData (C:\Projects\azure\node_modules\nodemailer\lib\smtp-connection\index.js:189:44) {
code: 'EAUTH',
command: 'API'
}
It executes when I run this script file alone locally. But throws an error when I call it from index.js file of the azure function app. I'm unsure if using google api/ OAUTH is mandatory for azure function app.
Your error code shared shows that NodeMailers is unable to verify your identity.
code: 'EAUTH', command: 'API'
Issue found:
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD,
},
Authentication variables used are environment variable.
This works when running locally because you must have an .env file with these variables hosted on your local server.
Solution:
You need to add all environment variables under as "New Application Settings" under "Application Settings" in "Configuration" (Settings Panel).
Doc reference - https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal
Add the values as under :
Name - EMAIL , value - <youremail>
Name - PASSORD, value - <password>
This should fix the auth issue.
I'm trying to setup the strapi application with nodemailer.
I've added the nodemailer dependency with yarn add #strapi/provider-email-nodemailer as on the official page described. Afterwards I've added the following configuration to my plugins.js file (I've replaced sensitive informations with XXXXXXXX):
module.exports = ({ env }) => ({
email: {
config: {
provider: 'nodemailer',
providerOptions: {
host: env('SMTP_HOST', 'XXXXXXXX'),
port: env('SMTP_PORT', 587),
auth: {
user: env('SMTP_USERNAME', 'XXXXXXXX'),
pass: env('SMTP_PASSWORD', 'XXXXXXXX'),
},
secure: true
},
settings: {
defaultFrom: 'XXXXXXXX',
defaultReplyTo: 'XXXXXXXX',
},
},
},
});
But when I try to strap Strapi with yarn develop I get the following error message:
C:\Dev\Strapi\Projects\strapi>yarn develop
yarn run v1.22.15
$ strapi develop
Building your admin UI with development configuration ...
Admin UI built successfully
[2021-12-27 23:27:51.485] debug: ⛔️ Server wasn't able to start properly.
[2021-12-27 23:27:51.487] error: Could not load email provider "nodemailer".
Error: Could not load email provider "nodemailer".
at createProvider (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\plugin-email\server\bootstrap.js:23:11)
at Object.module.exports [as bootstrap] (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\plugin-email\server\bootstrap.js:31:37)
at Object.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\core\domain\module\index.js:40:47)
at Object.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\core\registries\modules.js:28:19)
at async Strapi.runLifecyclesFunctions (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:463:5)
at async Strapi.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:401:5)
at async Strapi.load (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:410:5)
at async Strapi.start (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:161:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
What am I doing wrong? The configuration seems so simple so I don't have any idea what's wrong.
You need remove config section:
email: {
provider: 'nodemailer',
providerOptions: {
host: env('SMTP_HOST', 'smtp.xxxxxx.xx'),
port: env('SMTP_PORT', xxx),
secure: true,
auth: {
user: env('SMTP_USERNAME'),
pass: env('SMTP_PASSWORD'),
},
},
settings: {
defaultFrom: env('SMTP_FROM_EMAIL'),
defaultReplyTo: env('SMTP_REPLY_EMAIL'),
},
},
UPD: Sorry, I understood now that I use this package https://www.npmjs.com/package/strapi-provider-email-nodemailer and you used this https://www.npmjs.com/package/#strapi/provider-email-nodemailer
I'm trying to create a new Cloud Run service from firebase functions using the googleapis client library. The following code:
const auth = new google.auth.GoogleAuth({
projectId,
scopes: ['https://www.googleapis.com/auth/cloud-platform']
});
const authClient = await auth.getClient();
const result = await google.run({
version: 'v1',
auth: authClient
}).namespaces.services.create({
parent: `namespaces/${projectId}`,
requestBody: {
metadata: {
name: 'asdf'
},
spec: {
template: {
spec: {
containers: [
{
image: 'gcr.io/graph-4d1ec/graph#sha256:80c764961657d7e2fe548b3886c4662c55c9b5ac881aad5a74cce2d1f97895b8',
env: [
{ name: 'URL', value: url }
]
}
]
}
},
traffic: [{ percent: 100, latestRevision: true }]
}
}
}, {})
Produces an error:
Error: The request has errors
at Gaxios._request (/srv/node_modules/gaxios/build/src/gaxios.js:85:23)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
No further information is provided as to what is wrong with this request.
What am I doing wrong?
Most notably, the API client library you're using by default points to run.googleapis.com.
However, while using namespaces.services.create, you need a regional api endpoint, such as us-central1-run.googleapis.com. I'm not familiar with Node.js but you need to change the API endpoint from the default to this value.
You are in super luck, I just published a blog post several 5 minutes ago explaining how does gcloud run deploy work under the covers, with details on API calls, how updates are made etc. https://ahmet.im/blog/gcloud-run-deploy/ It has sample Go code linked at the end that you can study. Note that "updating" Cloud Run services has several other intricacies to understand, so make sure to check out the blog post.
Furthermore, to debug the issue you are having, I'm assuming (again I know nothing about Node.js) you might find more info in the result object that storing some error value or http response code or body.
I want to send a verification Email to new people signing up via AWS SES in Node.js:
var params = {
Destination: {
ToAddresses: [
'...',
]
},
Message: {
Body: {
Html: {
Data: '...',
Charset: 'utf-8'
},
Text: {
Data: '...',
Charset: 'utf-8'
}
},
Subject: {
Data: '...',
Charset: 'utf-8'
}
},
Source: '...',
ReturnPath: '...',
};
const ses = new AWS.SES({
my_accessKeyId,
my_secretAccessKey,
my_region,
})
ses.sendEmail(params, function (err, data) {
// ...
});
Unfortunately, nothing happens and after a minute or so I get the following error:
{ Error: connect ETIMEDOUT 35.157.44.176:443
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
message: 'connect ETIMEDOUT 35.157.44.176:443',
code: 'NetworkingError',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '35.157.44.176',
port: 443,
region: 'eu-central-1',
hostname: 'email.eu-central-1.amazonaws.com',
retryable: true,
time: 2018-10-18T16:52:00.803Z }
I am not sure if the error results from a mistake in my code, as I am currently only using the sandbox environment. But I verified the sending and receiving email, which should work fine even in sandbox mode.
P.S. I am not quite sure how to properly test my application when being in sandbox mode, as I am not allowed to send to unverified emails. Is it possible to request production access without a proper application running?
You need to change region from eu-central-1 to region where endpoint exist (eg. eu-west-1) in order to send emails out
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html
It's not obvious, so we'll need to do some troubleshooting.
First, lets see if you can connect from your local machine to the SES API using the AWS CLI. Make sure you have set up the aws credentials using aws configure and try:
aws ses list-identities
If this works, you should see a list of validated email addresses.
If not, you will see an error (permissions maybe), or a timeout suggests a network connectivity issue.
Note on credentials: Don't include your credentials in your code, either configure a .credentials file, which happens when you used the aws configure above, load it from a shared json file or use environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY).
Next, try to do the same in code:
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'eu-central-1'});
// Create SES Client
const ses = new AWS.SES({apiVersion: '2010-12-01'})
// Create params
var params = {
IdentityType: "EmailAddress",
MaxItems: 123,
NextToken: ""
};
ses.listIdentities(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
After you set up your credentials as mentioned above, use this in your Send Email code to create the ses client:
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: myregion});
// Create SES Client
const ses = new AWS.SES({apiVersion: '2010-12-01'})
Other things to check:
Make sure that all the email addresses are verified ("From", "Source", "Sender", or "Return-Path")
Make sure that you have the correct SES Access Keys
If using EC2, make sure that the security groups allow access to the AWS API.
I hope it's working by now, if not I can only say go to this page and make sure you haven't missed anything obvious.
You need to make sure your user your using to send the email
my_accessKeyId,
my_secretAccessKey,
has the correct IAM permissions (role attached to it) to send the email with ses. Test with the role SES full access I believe.
I have a migrated Parse application running on Parse 2.1.6. It uses a simple MongoDB 3.0.8 (RocksDB engine) setup, with authentication. The user it's using has the permissions:
[{ "role" : "dbAdmin", "db" : "parse" },
{ "role" : "readWrite", "db" : "parse"}]
When the Parse server boots up or tries to handle any request, I get:
[MongoError: not authorized for query on parse._SCHEMA]
Which seems very weird, given that:
the user clearly has permissions to query any collection on this database,
that same user is indeed able to query this collection via mongo console or robomongo,
Parse.com works normally when using this database, with that same user,
I can actually run the same Parse application locally, pointing to this same remote MongoDB with that user, and it works without such errors.
This is kinda crazy. I get the feeling that I'm missing something pretty basic here. Any thoughts?
UPDATE:
As request, sample code showing how the server is booting:
var api = new ParseServer({ appId: 'the app id',
masterKey: 'the master key',
clientKey: 'client key',
cloud: '/absolute_path/cloud/main.js',
serverURL: 'https://myserver.com/parse',
push:
{ ios:
{ production: false,
bundleId: 'thebundleid.com',
pfx: <Buffer ... > } },
oauth: { facebook: { appIds: 'appId' } },
databaseURI: 'mongodb://user#pass:127.0.0.1:27017'
});
app.use('/parse', api);