Skip to content

Commit f620059

Browse files
committed
removed helmet
1 parent a6166eb commit f620059

5 files changed

Lines changed: 48 additions & 48 deletions

File tree

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import helmet from "helmet";
22
import cors from "cors";
3-
// import rateLimit from "express-rate-limit";
4-
import { Application, Request, Response, NextFunction } from "express";
3+
import rateLimit from "express-rate-limit";
4+
import { Application } from "express";
55
import { Service } from "../config";
66

77
export const applySecurityMiddleware = (app: Application) => {
88
// Add request logging
9-
app.use((req: Request, res: Response, next: NextFunction) => {
10-
console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`);
11-
console.log('Headers:', JSON.stringify(req.headers));
12-
next();
13-
});
9+
// app.use((req: Request, res: Response, next: NextFunction) => {
10+
// console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`);
11+
// console.log('Headers:', JSON.stringify(req.headers));
12+
// next();
13+
// });
1414

15-
app.use(helmet({
16-
crossOriginResourcePolicy: { policy: "cross-origin" },
17-
}));
15+
// app.use(helmet({
16+
// crossOriginResourcePolicy: { policy: "cross-origin" },
17+
// }));
1818

19-
console.log('Setting up CORS with client URL:', Service.CLIENT_URL);
19+
// console.log('Setting up CORS with client URL:', Service.CLIENT_URL);
2020

2121
app.use(cors({
2222
origin: "*",
@@ -26,10 +26,10 @@ export const applySecurityMiddleware = (app: Application) => {
2626
exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type']
2727
}));
2828

29-
// const limiter = rateLimit({
30-
// windowMs: 15 * 60 * 1000, // 15 minutes (fixed from 15 * 16 * 1000 which was incorrect)
31-
// max: 100
32-
// });
29+
const limiter = rateLimit({
30+
windowMs: 15 * 60 * 1000, // 15 minutes (fixed from 15 * 16 * 1000 which was incorrect)
31+
max: 100
32+
});
3333

34-
// app.use(limiter);
34+
app.use(limiter);
3535
};

auth-service/src/presentation/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { dependencies } from "../__boot/dependencies";
1010
import { routes } from "../infrastructure/routes";
1111
import { errorHandler } from "../_lib/common/error";
1212
// import { multerError } from "../_lib/common/error/multerError";
13-
// import cors from "cors";
13+
import cors from "cors";
1414
const app:Application = express();
1515

1616
app.use(express.json())
@@ -30,13 +30,13 @@ if(process.env.NODE_ENV === "development"){
3030
// }));
3131

3232

33-
// app.use(cors({
34-
// origin: 'https://v-learning-client-5r8j.vercel.app',
35-
// methods: ["GET", "POST", "HEAD", "PUT", "PATCH", "DELETE", "OPTIONS"],
36-
// credentials: true,
37-
// allowedHeaders: ['Content-Type', 'Authorization', 'Cookie', 'Range', 'Accept'],
38-
// exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type']
39-
// }));
33+
app.use(cors({
34+
origin: 'https://v-learning-client-5r8j.vercel.app',
35+
methods: ["GET", "POST", "HEAD", "PUT", "PATCH", "DELETE", "OPTIONS"],
36+
credentials: true,
37+
allowedHeaders: ['Content-Type', 'Authorization', 'Cookie', 'Range', 'Accept'],
38+
exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type']
39+
}));
4040

4141
app.use('/',routes(dependencies));
4242

chat-service/src/presentation/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { dependencies } from "../__boot/dependencies";
88
import { createServer } from "http";
99
import connectSokcetIo from "../infrastructure/socket/connection";
1010
import { SocketService } from "../infrastructure/socket/SocketService";
11-
// import cors from 'cors';
11+
import cors from 'cors';
1212
import { errorHandler } from "../_lib/error";
1313

1414
dotenv.config();
@@ -29,13 +29,13 @@ const allowedOrigins = process.env.CLIENT_URL;
2929

3030
// app.use(cors(corsOptions));
3131

32-
// app.use(cors({
33-
// origin:allowedOrigins,
34-
// credentials: true,
35-
// allowedHeaders: ['Authorization', 'Content-Type', 'Range', 'Accept'],
36-
// exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type'],
37-
// methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
38-
// }));
32+
app.use(cors({
33+
origin:allowedOrigins,
34+
credentials: true,
35+
allowedHeaders: ['Authorization', 'Content-Type', 'Range', 'Accept'],
36+
exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type'],
37+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS','HEAD']
38+
}));
3939

4040

4141
const server = createServer(app);

course-srv/src/presentation/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config();
1010
import { errorHandler } from "../_lib/error";
1111
import {routes} from "../infrastructure/routes";
1212
import { dependencies } from "../__boot/dependencies";
13-
// import cors from 'cors';
13+
import cors from 'cors';
1414

1515

1616
const app: Application = express();
@@ -31,13 +31,13 @@ app.use(cookieParser());
3131
// }));
3232

3333

34-
// app.use(cors({
35-
// origin: 'https://v-learning-client-5r8j.vercel.app',
36-
// credentials: true,
37-
// allowedHeaders: ['Authorization', 'Content-Type', 'Range', 'Accept'],
38-
// exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type'],
39-
// methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
40-
// }));
34+
app.use(cors({
35+
origin: 'https://v-learning-client-5r8j.vercel.app',
36+
credentials: true,
37+
allowedHeaders: ['Authorization', 'Content-Type', 'Range', 'Accept'],
38+
exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type'],
39+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS','HEAD']
40+
}));
4141

4242

4343
// Add helmet with CORP configuration

notification-service/src/presentation/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import dotenv from "dotenv";
33
import cookieParser from "cookie-parser";
44
import { notificationRoutes } from '../infrastructure/routes';
55
import { dependencies } from '../__boot/dependencies';
6-
// import cors from 'cors'
6+
import cors from 'cors'
77

88
dotenv.config();
99

@@ -14,13 +14,13 @@ app.use(express.json());
1414
app.use(express.urlencoded({extended:true}));
1515
app.use(cookieParser());
1616

17-
// app.use(cors({
18-
// origin: 'https://v-learning-client-5r8j.vercel.app',
19-
// credentials: true,
20-
// allowedHeaders: ['Authorization', 'Content-Type', 'Range', 'Accept'],
21-
// exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type'],
22-
// methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
23-
// }));
17+
app.use(cors({
18+
origin: 'https://v-learning-client-5r8j.vercel.app',
19+
credentials: true,
20+
allowedHeaders: ['Authorization', 'Content-Type', 'Range', 'Accept'],
21+
exposedHeaders: ['Content-Disposition', 'Content-Range', 'Accept-Ranges', 'Content-Length', 'Content-Type'],
22+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS','HEAD']
23+
}));
2424

2525

2626
app.get("/",(req:Request, res:Response) => {

0 commit comments

Comments
 (0)