diff --git a/backend/.env.example b/backend/.env.example index 184aa64..4b295d0 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -11,6 +11,8 @@ SEED_ADMIN_PASSWORD= # URL publique de l'API (QR d'inscription, liens e-mail, images Google Wallet) — HTTPS en production # Production : PUBLIC_URL=https://api.monespacepro.eu (sous-domaine à confirmer) PUBLIC_URL=http://localhost:3100 +# Adresse des pages clients (/c/…, /carte/…). Production : WEB_URL=https://monespacepro.eu +WEB_URL= # Apple Wallet — fichiers PEM hors du dépôt (voir docs/wallet.md) APPLE_PASS_TYPE_ID= diff --git a/backend/backen.zip b/backend/backen.zip deleted file mode 100644 index 72efd17..0000000 Binary files a/backend/backen.zip and /dev/null differ diff --git a/backend/src/config/configuration.ts b/backend/src/config/configuration.ts index 62bf71f..e9b6ecf 100644 --- a/backend/src/config/configuration.ts +++ b/backend/src/config/configuration.ts @@ -3,6 +3,8 @@ export default () => ({ port: parseInt(process.env.PORT ?? '3100', 10), /** URL publique de l'API (liens e-mail, QR d'inscription, images Google Wallet). */ publicUrl: (process.env.PUBLIC_URL ?? 'http://localhost:3100').replace(/\/$/, ''), + /** Adresse des pages vues par les clients (QR d'inscription, lien de la carte). Par défaut : PUBLIC_URL. */ + webUrl: (process.env.WEB_URL || process.env.PUBLIC_URL || 'http://localhost:3100').replace(/\/$/, ''), cors: { origins: process.env.CORS_ORIGINS ?? '' }, jwt: { accessSecret: process.env.JWT_ACCESS_SECRET ?? 'dev-access-secret', diff --git a/backend/src/enrollment/enrollment.service.ts b/backend/src/enrollment/enrollment.service.ts index 0ecb1b3..4955a2b 100644 --- a/backend/src/enrollment/enrollment.service.ts +++ b/backend/src/enrollment/enrollment.service.ts @@ -100,7 +100,7 @@ export class EnrollmentService { } cardUrl(card: { serial: string; accessKey: string }) { - return `${this.config.get('publicUrl')}/carte/${card.serial}?k=${card.accessKey}`; + return `${this.config.get('webUrl')}/carte/${card.serial}?k=${card.accessKey}`; } private findCardByEmail(storeId: string, email: string) { diff --git a/backend/src/stores/stores.service.ts b/backend/src/stores/stores.service.ts index 846cd50..7462ee1 100644 --- a/backend/src/stores/stores.service.ts +++ b/backend/src/stores/stores.service.ts @@ -57,7 +57,7 @@ export class StoresService { ...this.present(s), counts: _count, subscription, - enrollUrl: `${this.config.get('publicUrl')}/c/${s.slug}`, + enrollUrl: `${this.config.get('webUrl')}/c/${s.slug}`, }; } diff --git a/backend/src/wallet/apple-pass.service.ts b/backend/src/wallet/apple-pass.service.ts index acff3c8..97994b5 100644 --- a/backend/src/wallet/apple-pass.service.ts +++ b/backend/src/wallet/apple-pass.service.ts @@ -68,7 +68,7 @@ export class ApplePassService { { key: 'manage', label: 'Ma carte', - value: `${this.config.get('publicUrl')}/carte/${card.serial}?k=${card.accessKey}`, + value: `${this.config.get('webUrl')}/carte/${card.serial}?k=${card.accessKey}`, }, { key: 'powered', label: '', value: 'Propulsé par MonEspacePro' }, ], diff --git a/backend/src/wallet/google-wallet.service.ts b/backend/src/wallet/google-wallet.service.ts index 849fe12..7d28a1d 100644 --- a/backend/src/wallet/google-wallet.service.ts +++ b/backend/src/wallet/google-wallet.service.ts @@ -39,6 +39,7 @@ export class GoogleWalletService { if (!design) throw new ServiceUnavailableException('Carte non conçue'); const publicUrl: string = this.config.get('publicUrl')!; + const webUrl: string = this.config.get('webUrl')!; const image = (path: string, description: string) => ({ sourceUri: { uri: `${publicUrl}/uploads/${path}` }, contentDescription: { defaultValue: { language: 'fr-FR', value: description } }, @@ -72,13 +73,13 @@ export class GoogleWalletService { barcode: { type: 'QR_CODE', value: card.serial }, textModulesData: [{ id: 'rewards', header: 'Récompenses', body: rewardsText(card) }], linksModuleData: { - uris: [{ id: 'manage', uri: `${publicUrl}/carte/${card.serial}?k=${card.accessKey}`, description: 'Ma carte' }], + uris: [{ id: 'manage', uri: `${webUrl}/carte/${card.serial}?k=${card.accessKey}`, description: 'Ma carte' }], }, }; const key = await importPKCS8(account.private_key, 'RS256'); const jwt = await new SignJWT({ - origins: [publicUrl], + origins: [publicUrl, webUrl], typ: 'savetowallet', payload: { loyaltyClasses: [loyaltyClass], loyaltyObjects: [loyaltyObject] }, }) diff --git a/docs/deploiement.md b/docs/deploiement.md index 795945d..9257d97 100644 --- a/docs/deploiement.md +++ b/docs/deploiement.md @@ -78,6 +78,28 @@ Si `node` est introuvable depuis cron, le journal donne le chemin exact à ajout Mise à jour de l'admin : `npm run build` puis remplacer les fichiers. Pas de redémarrage. +## 5 bis. Site vitrine `monespacepro.eu` + pages clients +Les liens montrés aux clients (QR d'inscription `/c/`, lien de la carte `/carte/`) sont sur **monespacepro.eu** +(`WEB_URL=https://monespacepro.eu` dans le `.env` de l'API). Le site vitrine est statique ; nginx transmet ces chemins à l'API. + +1. CloudPanel → *Add Site* → *Static HTML Site* : `monespacepro.eu` (alias `www.monespacepro.eu`), envoyer le contenu de `site/`. +2. Onglet **Vhost** du site : dans le premier bloc `server { … }` (celui qui écoute en 443), **avant** `location / {`, ajouter : + ```nginx + # Pages et API publiques des clients → API MonEspacePro (port 3100) + location ~ ^/(c|carte|api/public|uploads|static)/ { + proxy_pass http://127.0.0.1:3100; + proxy_set_header Host $host; + # Derrière Cloudflare : la vraie IP du client (limites anti-abus) + proxy_set_header X-Forwarded-For $http_cf_connecting_ip; + proxy_set_header X-Forwarded-Proto https; + client_max_body_size 1m; + } + ``` +3. SSL/TLS → Let's Encrypt (ou certificat d'origine Cloudflare si le proxy orange est activé, mode SSL **Full (strict)**). +4. Dans le `.env` de l'API : `WEB_URL=https://monespacepro.eu`, puis fichier `RESTART`. + +Les anciennes adresses `https://api.monespacepro.eu/c/…` continuent de fonctionner (affichettes déjà imprimées). + ## 6. Surveillance externe (alerte si tout le serveur tombe) Le watchdog ne peut rien si le serveur entier est arrêté. Créer deux sondes gratuites sur **UptimeRobot** (ou équivalent), toutes les 5 min, alerte par e-mail : - `https://api.monespacepro.eu/api/health/ready` → API **et** base de données ;