Liens clients sur monespacepro.eu (WEB_URL) au lieu de api.monespacepro.eu
QR d'inscription, lien de la carte (e-mail, Apple Wallet, Google Wallet) utilisent WEB_URL ; repli sur PUBLIC_URL si absent. Vhost nginx du site vitrine documenté pour transmettre /c, /carte, /api/public à l'API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ecf287e317
commit
526c0fee50
8 changed files with 32 additions and 5 deletions
|
|
@ -11,6 +11,8 @@ SEED_ADMIN_PASSWORD=
|
||||||
# URL publique de l'API (QR d'inscription, liens e-mail, images Google Wallet) — HTTPS en production
|
# 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)
|
# Production : PUBLIC_URL=https://api.monespacepro.eu (sous-domaine à confirmer)
|
||||||
PUBLIC_URL=http://localhost:3100
|
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 Wallet — fichiers PEM hors du dépôt (voir docs/wallet.md)
|
||||||
APPLE_PASS_TYPE_ID=
|
APPLE_PASS_TYPE_ID=
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -3,6 +3,8 @@ export default () => ({
|
||||||
port: parseInt(process.env.PORT ?? '3100', 10),
|
port: parseInt(process.env.PORT ?? '3100', 10),
|
||||||
/** URL publique de l'API (liens e-mail, QR d'inscription, images Google Wallet). */
|
/** URL publique de l'API (liens e-mail, QR d'inscription, images Google Wallet). */
|
||||||
publicUrl: (process.env.PUBLIC_URL ?? 'http://localhost:3100').replace(/\/$/, ''),
|
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 ?? '' },
|
cors: { origins: process.env.CORS_ORIGINS ?? '' },
|
||||||
jwt: {
|
jwt: {
|
||||||
accessSecret: process.env.JWT_ACCESS_SECRET ?? 'dev-access-secret',
|
accessSecret: process.env.JWT_ACCESS_SECRET ?? 'dev-access-secret',
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ export class EnrollmentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
cardUrl(card: { serial: string; accessKey: string }) {
|
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) {
|
private findCardByEmail(storeId: string, email: string) {
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export class StoresService {
|
||||||
...this.present(s),
|
...this.present(s),
|
||||||
counts: _count,
|
counts: _count,
|
||||||
subscription,
|
subscription,
|
||||||
enrollUrl: `${this.config.get('publicUrl')}/c/${s.slug}`,
|
enrollUrl: `${this.config.get('webUrl')}/c/${s.slug}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ export class ApplePassService {
|
||||||
{
|
{
|
||||||
key: 'manage',
|
key: 'manage',
|
||||||
label: 'Ma carte',
|
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' },
|
{ key: 'powered', label: '', value: 'Propulsé par MonEspacePro' },
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ export class GoogleWalletService {
|
||||||
if (!design) throw new ServiceUnavailableException('Carte non conçue');
|
if (!design) throw new ServiceUnavailableException('Carte non conçue');
|
||||||
|
|
||||||
const publicUrl: string = this.config.get('publicUrl')!;
|
const publicUrl: string = this.config.get('publicUrl')!;
|
||||||
|
const webUrl: string = this.config.get('webUrl')!;
|
||||||
const image = (path: string, description: string) => ({
|
const image = (path: string, description: string) => ({
|
||||||
sourceUri: { uri: `${publicUrl}/uploads/${path}` },
|
sourceUri: { uri: `${publicUrl}/uploads/${path}` },
|
||||||
contentDescription: { defaultValue: { language: 'fr-FR', value: description } },
|
contentDescription: { defaultValue: { language: 'fr-FR', value: description } },
|
||||||
|
|
@ -72,13 +73,13 @@ export class GoogleWalletService {
|
||||||
barcode: { type: 'QR_CODE', value: card.serial },
|
barcode: { type: 'QR_CODE', value: card.serial },
|
||||||
textModulesData: [{ id: 'rewards', header: 'Récompenses', body: rewardsText(card) }],
|
textModulesData: [{ id: 'rewards', header: 'Récompenses', body: rewardsText(card) }],
|
||||||
linksModuleData: {
|
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 key = await importPKCS8(account.private_key, 'RS256');
|
||||||
const jwt = await new SignJWT({
|
const jwt = await new SignJWT({
|
||||||
origins: [publicUrl],
|
origins: [publicUrl, webUrl],
|
||||||
typ: 'savetowallet',
|
typ: 'savetowallet',
|
||||||
payload: { loyaltyClasses: [loyaltyClass], loyaltyObjects: [loyaltyObject] },
|
payload: { loyaltyClasses: [loyaltyClass], loyaltyObjects: [loyaltyObject] },
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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/<slug>`, lien de la carte `/carte/<n°>`) 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)
|
## 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 :
|
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 ;
|
- `https://api.monespacepro.eu/api/health/ready` → API **et** base de données ;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue