mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
task: add trust proxy header (#411)
* task: add trust proxy header * add logging
This commit is contained in:
24
src/main.ts
24
src/main.ts
@ -1,15 +1,14 @@
|
|||||||
|
import { RequestContextMiddleware } from '@app/common/middleware/request-context.middleware';
|
||||||
|
import { SeederService } from '@app/common/seed/services/seeder.service';
|
||||||
|
import { Logger, ValidationPipe } from '@nestjs/common';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { AppModule } from './app.module';
|
import { json, urlencoded } from 'body-parser';
|
||||||
import rateLimit from 'express-rate-limit';
|
import rateLimit from 'express-rate-limit';
|
||||||
import helmet from 'helmet';
|
import helmet from 'helmet';
|
||||||
import { setupSwaggerAuthentication } from '../libs/common/src/util/user-auth.swagger.utils';
|
|
||||||
import { ValidationPipe } from '@nestjs/common';
|
|
||||||
import { json, urlencoded } from 'body-parser';
|
|
||||||
import { SeederService } from '@app/common/seed/services/seeder.service';
|
|
||||||
import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter';
|
|
||||||
import { Logger } from '@nestjs/common';
|
|
||||||
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
|
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
|
||||||
import { RequestContextMiddleware } from '@app/common/middleware/request-context.middleware';
|
import { setupSwaggerAuthentication } from '../libs/common/src/util/user-auth.swagger.utils';
|
||||||
|
import { AppModule } from './app.module';
|
||||||
|
import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
@ -27,9 +26,18 @@ async function bootstrap() {
|
|||||||
rateLimit({
|
rateLimit({
|
||||||
windowMs: 5 * 60 * 1000,
|
windowMs: 5 * 60 * 1000,
|
||||||
max: 500,
|
max: 500,
|
||||||
|
standardHeaders: true,
|
||||||
|
legacyHeaders: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
console.log('Real IP:', req.ip);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.getHttpAdapter().getInstance().set('trust proxy', 1);
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
helmet({
|
helmet({
|
||||||
contentSecurityPolicy: false,
|
contentSecurityPolicy: false,
|
||||||
|
Reference in New Issue
Block a user