dword-design / nuxt-mail

Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails.
Other
247 stars 18 forks source link

Cannot set headers after they are sent #259

Open andreasvirkus opened 2 weeks ago

andreasvirkus commented 2 weeks ago

Currently calling

const mail = useMail()

await mail.send({
  from: 'Website',
  subject: 'Form',
  text: `${name.value}
E-mail: ${email.value}
Msg: ${message.value}`,
})

Results in a 500 error logged (only on prod), it works fine locally. Is the API_URL env still required or the axios dependency? From the docs it's hard to tell if that's only for Nuxt 2 or also for Nuxt 3

Error:

homepage-2    | [nuxt] [request error] [unhandled] [500] Cannot set headers after they are sent to the client
homepage-2    |   at ServerResponse.setHeader (node:_http_outgoing:699:11)
homepage-2    |   at setResponseHeaders$1 (./.output/server/chunks/runtime.mjs:1751:20)
homepage-2    |   at Object.handler (./.output/server/chunks/runtime.mjs:5643:7)
homepage-2    |   at Object.handler (./.output/server/chunks/runtime.mjs:2270:31)
homepage-2    |   at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
homepage-2    |   at async Server.toNodeHandle (./.output/server/chunks/runtime.mjs:2540:7)

The response of the /send/mail API endpoint in the browser's dev tools is

message: "Missing credentials for \"PLAIN\""
stack: ""
statusCode: 500
statusMessage: "Missing credentials for \"PLAIN\""
url: mail/send"