mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 06:28:12 +00:00
Update main.ts
This commit is contained in:
@@ -2,6 +2,7 @@ import "reflect-metadata";
|
|||||||
import * as dotenv from "dotenv";
|
import * as dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
import { NestFactory } from "@nestjs/core";
|
import { NestFactory } from "@nestjs/core";
|
||||||
|
import type { NestExpressApplication } from "@nestjs/platform-express";
|
||||||
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
||||||
import {
|
import {
|
||||||
HttpExceptionFilter,
|
HttpExceptionFilter,
|
||||||
@@ -11,8 +12,25 @@ import {
|
|||||||
|
|
||||||
import { AppModule } from "./app.module";
|
import { AppModule } from "./app.module";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON body ceiling. Signing posts the signature AND the company stamp as
|
||||||
|
* base64 in one JSON body, and base64 inflates bytes by ~4/3 — a 10MB stamp is
|
||||||
|
* ~13.4MB on the wire. Express defaults to 100kb, which rejected any real stamp
|
||||||
|
* image with a 413 "request entity too large".
|
||||||
|
*/
|
||||||
|
const JSON_BODY_LIMIT = '20mb';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||||
|
|
||||||
|
// Nest's own body-parser API, NOT `app.use(json(...))` from express: express
|
||||||
|
// is not a declared dependency of this app (it arrives under
|
||||||
|
// @nestjs/platform-express), so importing it directly resolved only through
|
||||||
|
// pnpm's hoisted dev store and died as MODULE_NOT_FOUND in the production
|
||||||
|
// image, where `pnpm deploy --prod` installs declared dependencies only.
|
||||||
|
// This also RECONFIGURES the default parsers rather than racing them.
|
||||||
|
app.useBodyParser('json', { limit: JSON_BODY_LIMIT });
|
||||||
|
app.useBodyParser('urlencoded', { limit: JSON_BODY_LIMIT, extended: true });
|
||||||
|
|
||||||
// Dev CORS: reflect any localhost origin and allow credentials so the
|
// Dev CORS: reflect any localhost origin and allow credentials so the
|
||||||
// freight portal (5173), passenger portal (5174), backoffices (5183/5184)
|
// freight portal (5173), passenger portal (5174), backoffices (5183/5184)
|
||||||
@@ -28,6 +46,9 @@ async function bootstrap() {
|
|||||||
"Accept",
|
"Accept",
|
||||||
"Authorization",
|
"Authorization",
|
||||||
"X-Requested-With",
|
"X-Requested-With",
|
||||||
|
// Which freight frontend is calling — /auth/login uses this to reject
|
||||||
|
// cross-audience credentials (EDRFREIGHT-415).
|
||||||
|
"X-Client-App",
|
||||||
// IAM context headers required by @tria-plc/api-common's JwtGuard
|
// IAM context headers required by @tria-plc/api-common's JwtGuard
|
||||||
"organization-unit-id",
|
"organization-unit-id",
|
||||||
"delegator-position-id",
|
"delegator-position-id",
|
||||||
@@ -40,6 +61,13 @@ async function bootstrap() {
|
|||||||
"x-delegator-position-id",
|
"x-delegator-position-id",
|
||||||
"x-current-project-id",
|
"x-current-project-id",
|
||||||
"x-current-position-id",
|
"x-current-position-id",
|
||||||
|
// Headers sent by the freight-backoffice OKR/objective-service client
|
||||||
|
// (withHeaders.tsx, signatureAndTeeterService.ts, useIncomingReport.ts)
|
||||||
|
// under yet another naming convention — unprefixed "tenant-key"/"unit-id",
|
||||||
|
// and "x-delegated-position-id" (delegated, not delegator).
|
||||||
|
"tenant-key",
|
||||||
|
"unit-id",
|
||||||
|
"x-delegated-position-id",
|
||||||
],
|
],
|
||||||
exposedHeaders: ["Content-Disposition"],
|
exposedHeaders: ["Content-Disposition"],
|
||||||
maxAge: 86400, // cache preflight for 24h to cut chatter in dev
|
maxAge: 86400, // cache preflight for 24h to cut chatter in dev
|
||||||
|
|||||||
Reference in New Issue
Block a user