Support LiteSpeed /server path via GLOBAL_PREFIX

Allow Nest prefix server/api and overlay dist from git onto the deploy bundle so proxy paths match without a full retar.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-06 09:55:57 +03:30
co-authored by Cursor
parent 2d513a81af
commit b121797263
6 changed files with 19 additions and 11 deletions
+6 -4
View File
@@ -6,7 +6,9 @@ import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api');
// پشت LiteSpeed روی /server → GLOBAL_PREFIX=server/api
const globalPrefix = process.env.GLOBAL_PREFIX || 'api';
app.setGlobalPrefix(globalPrefix);
app.enableCors({
origin: true,
credentials: true,
@@ -27,11 +29,11 @@ async function bootstrap() {
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, swaggerConfig);
SwaggerModule.setup('api/docs', app, document);
SwaggerModule.setup(`${globalPrefix}/docs`, app, document);
const port = process.env.PORT ?? 3000;
await app.listen(port);
console.log(`Fabric Trade API listening on http://localhost:${port}/api`);
console.log(`Swagger docs at http://localhost:${port}/api/docs`);
console.log(`Fabric Trade API listening on http://localhost:${port}/${globalPrefix}`);
console.log(`Swagger docs at http://localhost:${port}/${globalPrefix}/docs`);
}
bootstrap();