Pages clients : redirection 301 de api.monespacepro.eu vers monespacepro.eu
/c/… et /carte/… ne sont servies que sur le domaine public (WEB_URL) ; les anciens liens et affichettes imprimées sont redirigés. Inactif si WEB_URL n'est pas distinct de PUBLIC_URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
72ea6e4faa
commit
ad344f5d95
3 changed files with 13 additions and 0 deletions
BIN
admin/si.zip
BIN
admin/si.zip
Binary file not shown.
|
|
@ -5,6 +5,7 @@ import { RequestMethod, ValidationPipe } from '@nestjs/common';
|
|||
import { ConfigService } from '@nestjs/config';
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import helmet from 'helmet';
|
||||
import type { NextFunction, Request, Response } from 'express';
|
||||
import { join } from 'path';
|
||||
import { AppModule } from './app.module';
|
||||
import { UPLOADS_DIR } from './card-design/card-design.service';
|
||||
|
|
@ -38,6 +39,18 @@ async function bootstrap() {
|
|||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
app.enableCors({ origin: origins.length ? origins : false, credentials: true });
|
||||
// Pages clients : toujours sur le domaine public (WEB_URL). Un ancien lien
|
||||
// api.monespacepro.eu/c/… (affichette déjà imprimée) est redirigé, pas servi.
|
||||
// Sans WEB_URL distinct de PUBLIC_URL (développement), aucune redirection.
|
||||
const webUrl = new URL(config.get<string>('webUrl')!);
|
||||
const separateWebHost = webUrl.hostname !== new URL(config.get<string>('publicUrl')!).hostname;
|
||||
app.use((req: Request, res: Response, next: NextFunction) => {
|
||||
const isClientPage = req.method === 'GET' && /^\/(c|carte)\//.test(req.path);
|
||||
if (separateWebHost && isClientPage && req.hostname !== webUrl.hostname) {
|
||||
return res.redirect(301, `${webUrl.origin}${req.originalUrl}`);
|
||||
}
|
||||
next();
|
||||
});
|
||||
// Logos et bandeaux des cartes (aperçu admin, page d'inscription, génération des pass).
|
||||
app.useStaticAssets(UPLOADS_DIR, { prefix: '/uploads/' });
|
||||
// Fichiers fixes de la plateforme (logo par défaut des cartes Google Wallet).
|
||||
|
|
|
|||
BIN
site/si.zip
Normal file
BIN
site/si.zip
Normal file
Binary file not shown.
Loading…
Reference in a new issue