When a webhooko form is parametered with no ressources, an email is send to the email user each time the form is filled.
This option, in a cloud-based option of webstudio.
So, for self-hosted instance, the repo could need a smtp service
Plan d'implémentation
Contexte technique
Quand un WebhookForm n'a pas de ressource configurée, l'action route handler appelle context.getDefaultActionResource?.() (interface définie dans extension.ts). En cloud, cette fonction appelle le propre endpoint email de Webstudio. En self-host, la fonction n'est jamais implémentée → "Resource not found".
Le publisher supporte trois modes : ssg (Vike, static), ssr (react-router-serve), docker (conteneur Docker). Seul le mode SSR/docker a un server action — le SSG est du HTML pur.
Deux repos impactés : webstudio-fork + webstudio-self-host (+ webstudio-publisher).
Étape 1 — webstudio-publisher : endpoint SMTP relay
Ajouter POST /api/form-email dans server.mjs :
- Installe
nodemailer
- Accepte
{ contactEmail, fields, pageUrl, projectId } en JSON
- Envoie via
SMTP_HOST/PORT/USER/PASS/FROM/SECURE
- Auth par
Authorization: Bearer ${FORM_EMAIL_SECRET} (secret partagé)
- Réponse
{ ok: true } ou { ok: false, error }
Étape 2 — webstudio-fork : implémenter getDefaultActionResource dans le template docker
Créer packages/cli/templates/react-router-docker/app/entry.server.ts qui fournit getDefaultActionResource via le load context React Router. La fonction retourne un ResourceRequest pointant vers PUBLISHER_INTERNAL_URL/api/form-email avec contactEmail + form data en body JSON, authentifié par FORM_EMAIL_SECRET.
Le publisher passe PUBLISHER_INTERNAL_URL et FORM_EMAIL_SECRET comme env vars quand il lance le conteneur SSR/docker.
Étape 3 — Mode SSG (Vike) : hors scope v1
En SSG pure, il n'y a pas de server action. Options futures :
- Publisher intercepte les
POST /_form-email dans son proxy + contactEmail dans un champ caché
- Ou documenter que la feature nécessite le mode SSR/docker
Étape 4 — webstudio-self-host : variables d'environnement
.env.example — ajouter :
# SMTP — for form email notifications (SSR publish mode only)
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=user@example.com
SMTP_PASS=yourpassword
SMTP_FROM="Webstudio Forms <noreply@example.com>"
FORM_EMAIL_SECRET=<openssl rand -hex 32>
docker-compose.yml et docker-compose.coolify.yml — service publisher :
environment:
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT:-587}
SMTP_SECURE: ${SMTP_SECURE:-false}
SMTP_USER: ${SMTP_USER}
SMTP_PASS: ${SMTP_PASS}
SMTP_FROM: ${SMTP_FROM}
FORM_EMAIL_SECRET: ${FORM_EMAIL_SECRET}
Ordre d'exécution recommandé
webstudio-publisher → endpoint /api/form-email
webstudio-fork → entry.server.ts + passage des env vars depuis le publisher
webstudio-self-host → .env.example + docker-compose
When a webhooko form is parametered with no ressources, an email is send to the email user each time the form is filled.
This option, in a cloud-based option of webstudio.
So, for self-hosted instance, the repo could need a smtp service
Plan d'implémentation
Contexte technique
Quand un
WebhookFormn'a pas de ressource configurée, l'action route handler appellecontext.getDefaultActionResource?.()(interface définie dansextension.ts). En cloud, cette fonction appelle le propre endpoint email de Webstudio. En self-host, la fonction n'est jamais implémentée →"Resource not found".Le publisher supporte trois modes :
ssg(Vike, static),ssr(react-router-serve),docker(conteneur Docker). Seul le mode SSR/docker a un server action — le SSG est du HTML pur.Deux repos impactés :
webstudio-fork+webstudio-self-host(+webstudio-publisher).Étape 1 —
webstudio-publisher: endpoint SMTP relayAjouter
POST /api/form-emaildansserver.mjs:nodemailer{ contactEmail, fields, pageUrl, projectId }en JSONSMTP_HOST/PORT/USER/PASS/FROM/SECUREAuthorization: Bearer ${FORM_EMAIL_SECRET}(secret partagé){ ok: true }ou{ ok: false, error }Étape 2 —
webstudio-fork: implémentergetDefaultActionResourcedans le template dockerCréer
packages/cli/templates/react-router-docker/app/entry.server.tsqui fournitgetDefaultActionResourcevia le load context React Router. La fonction retourne unResourceRequestpointant versPUBLISHER_INTERNAL_URL/api/form-emailaveccontactEmail+ form data en body JSON, authentifié parFORM_EMAIL_SECRET.Le publisher passe
PUBLISHER_INTERNAL_URLetFORM_EMAIL_SECRETcomme env vars quand il lance le conteneur SSR/docker.Étape 3 — Mode SSG (Vike) : hors scope v1
En SSG pure, il n'y a pas de server action. Options futures :
POST /_form-emaildans son proxy +contactEmaildans un champ cachéÉtape 4 —
webstudio-self-host: variables d'environnement.env.example— ajouter :docker-compose.ymletdocker-compose.coolify.yml— servicepublisher:Ordre d'exécution recommandé
webstudio-publisher→ endpoint/api/form-emailwebstudio-fork→entry.server.ts+ passage des env vars depuis le publisherwebstudio-self-host→.env.example+docker-compose