- POST /api/kontakt: validiert, Honeypot-Spamschutz, Rate-Limit (5/10min) - Versand per SMTP über eigenes Postfach, keine Speicherung/DB - CORS auf die eigene Website beschränkt (ALLOWED_ORIGIN) - Konfiguration komplett über Environment-Variablen (.env.example) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
1.3 KiB
Markdown
32 lines
1.3 KiB
Markdown
# kontakt-api
|
||
|
||
Winziger, selbst gehosteter Dienst, der das Kontaktformular von
|
||
`atilgan-gartenbau.de` entgegennimmt und als E-Mail über das eigene Postfach
|
||
verschickt. **Keine Datenbank, keine Speicherung** – die Daten verlassen den
|
||
eigenen Server nur als E-Mail an den Betreiber. Node.js + nodemailer.
|
||
|
||
## Endpunkt
|
||
`POST /api/kontakt` — JSON: `{ name, email, telefon, betreff, nachricht, website }`
|
||
(`website` = Honeypot, muss leer sein). Antwort: `{ ok: true }` oder Fehler.
|
||
`GET /health` — Health-Check.
|
||
|
||
## Deployment auf Coolify
|
||
1. Neue **Application** aus diesem Repo (`kontakt-api`) anlegen.
|
||
2. Build Pack: **Nixpacks** (erkennt Node automatisch, `npm start`). Kein Dockerfile nötig.
|
||
3. Eine **Domain/Subdomain** vergeben, z. B. `https://formular.atilgan-gartenbau.de`.
|
||
4. **Environment-Variablen** setzen (siehe `.env.example`), v. a.:
|
||
- `ALLOWED_ORIGIN` = die Live-Domain der Website
|
||
- `SMTP_HOST`, `SMTP_PORT`, `SMTP_SECURE`, `SMTP_USER`, `SMTP_PASS`
|
||
- `MAIL_TO` (Standard: info@adnan-atilgan.de)
|
||
5. Deployen. Test: `GET https://formular.atilgan-gartenbau.de/health` → `{ "ok": true }`.
|
||
|
||
Anschließend im Website-Repo in `js/main.js` die Konstante `KONTAKT_ENDPOINT`
|
||
auf `https://<eure-subdomain>/api/kontakt` setzen (falls abweichend).
|
||
|
||
## Lokal testen
|
||
```bash
|
||
npm install
|
||
cp .env.example .env # Werte eintragen
|
||
npm start
|
||
```
|