mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 07:07:21 +00:00
Compare commits
15 Commits
5cf45c30f4
...
test/preve
Author | SHA1 | Date | |
---|---|---|---|
4ff62611fb | |||
7d9fe170b9 | |||
5ad5e7e934 | |||
238a52bfa9 | |||
f2a8ed141c | |||
bf64470288 | |||
c1e9c6cbb7 | |||
f28184975f | |||
130a1ed06e | |||
01d66a67d9 | |||
069db9a3ea | |||
ce1986a27f | |||
6857b4ea03 | |||
e6c3fc7044 | |||
588eacdfef |
@ -37,6 +37,7 @@ import { VisitorPasswordModule } from './vistor-password/visitor-password.module
|
||||
|
||||
import { ThrottlerGuard } from '@nestjs/throttler';
|
||||
import { ThrottlerModule } from '@nestjs/throttler/dist/throttler.module';
|
||||
import { isArray } from 'class-validator';
|
||||
import { winstonLoggerOptions } from '../libs/common/src/logger/services/winston.logger';
|
||||
import { AqiModule } from './aqi/aqi.module';
|
||||
import { OccupancyModule } from './occupancy/occupancy.module';
|
||||
@ -50,7 +51,12 @@ import { WeatherModule } from './weather/weather.module';
|
||||
throttlers: [{ ttl: 60000, limit: 30 }],
|
||||
generateKey: (context) => {
|
||||
const req = context.switchToHttp().getRequest();
|
||||
return req.headers['x-forwarded-for'] || req.ip;
|
||||
console.log('Real IP:', req.headers['x-forwarded-for']);
|
||||
return req.headers['x-forwarded-for']
|
||||
? isArray(req.headers['x-forwarded-for'])
|
||||
? req.headers['x-forwarded-for'][0].split(':')[0]
|
||||
: req.headers['x-forwarded-for'].split(':')[0]
|
||||
: req.ip;
|
||||
},
|
||||
}),
|
||||
WinstonModule.forRoot(winstonLoggerOptions),
|
||||
|
12
src/main.ts
12
src/main.ts
@ -21,18 +21,6 @@ async function bootstrap() {
|
||||
|
||||
app.use(new RequestContextMiddleware().use);
|
||||
|
||||
app.use((req, res, next) => {
|
||||
console.log(
|
||||
'Real IP:',
|
||||
req.ip,
|
||||
req.headers['x-forwarded-for'],
|
||||
req.connection.remoteAddress,
|
||||
);
|
||||
next();
|
||||
});
|
||||
|
||||
// app.getHttpAdapter().getInstance().set('trust proxy', 1);
|
||||
|
||||
app.use(
|
||||
helmet({
|
||||
contentSecurityPolicy: false,
|
||||
|
Reference in New Issue
Block a user