Fix build issues and make SMTP config optional
This commit is contained in:
parent
38716dc80b
commit
b29a141fb8
@ -1,4 +1,15 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
reactStrictMode: true,
|
||||||
|
output: 'standalone',
|
||||||
|
images: {
|
||||||
|
domains: ['images.unsplash.com', 'localhost'],
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
SMTP_HOST: process.env.SMTP_HOST || 'smtp.example.com',
|
||||||
|
SMTP_PORT: process.env.SMTP_PORT || '587',
|
||||||
|
SMTP_USER: process.env.SMTP_USER || 'user@example.com',
|
||||||
|
SMTP_PASSWORD: process.env.SMTP_PASSWORD || 'default-password',
|
||||||
|
},s = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
images: {
|
images: {
|
||||||
|
|||||||
@ -8,11 +8,19 @@ export default async function handler(req, res) {
|
|||||||
try {
|
try {
|
||||||
const { name, email, message } = req.body;
|
const { name, email, message } = req.body;
|
||||||
|
|
||||||
// Nutze deine eigenen SMTP-Daten aus .env.local
|
// Prüfe ob SMTP konfiguriert ist
|
||||||
|
if (!process.env.SMTP_HOST || !process.env.SMTP_USER || !process.env.SMTP_PASSWORD) {
|
||||||
|
console.log('SMTP not configured, logging message instead:', { name, email, message });
|
||||||
|
return res.status(200).json({
|
||||||
|
message: 'Message logged (SMTP not configured)',
|
||||||
|
debug: { name, email, message }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
host: process.env.SMTP_HOST,
|
host: process.env.SMTP_HOST,
|
||||||
port: Number(process.env.SMTP_PORT) || 587,
|
port: Number(process.env.SMTP_PORT) || 587,
|
||||||
secure: Number(process.env.SMTP_PORT) === 465, // true für Port 465 (SSL), sonst false (STARTTLS)
|
secure: Number(process.env.SMTP_PORT) === 465,
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.SMTP_USER,
|
user: process.env.SMTP_USER,
|
||||||
pass: process.env.SMTP_PASSWORD,
|
pass: process.env.SMTP_PASSWORD,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user