Skip to content

Commit b896233

Browse files
committed
Update cors policy for all microservices
1 parent bf35b05 commit b896233

File tree

4 files changed

+5
-24
lines changed

4 files changed

+5
-24
lines changed

api_gateway/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ import cors from 'cors';
99

1010
const corsOptions = {
1111
origin: ["http://peerprep-g10.com", "https://peerprep-g10.com", "http://localhost:3000"],
12-
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
12+
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
13+
optionsSuccessStatus: 200,
14+
credentials: true,
1315
}
1416

1517

18+
1619
const httpApp = express();
1720
const httpProxyPort: number = parseInt(process.env.PORT || "8000");
1821

code_execution/src/index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
import express, { Request } from "express";
1+
import express from "express";
22
import bodyParser from "body-parser";
33
import { runSubmission } from "./executor_client";
44
import { callbacks } from "./shared";
5-
import cors from "cors";
65
import { v4 as uuidv4 } from "uuid";
76

8-
const corsOptions = {
9-
origin: 'http://localhost:3000', //TODO: need to add our production url here once we host it. Currently assuming all requests will be made from this url
10-
credentials: true, //access-control-allow-credentials:true
11-
optionSuccessStatus: 200
12-
}
13-
147
const app = express();
158
const port = process.env.PORT || 8090;
169

17-
app.use(cors<Request>(corsOptions));
1810
app.use(bodyParser.json());
1911
app.use(bodyParser.urlencoded({ extended: true }));
2012

question_service/src/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ connectDB().then((v) => {
1616

1717
const app = express()
1818

19-
app.use(cors({
20-
origin: 'http://localhost:3000',
21-
optionsSuccessStatus: 200,
22-
credentials: true, //access-control-allow-credentials:true
23-
}))
24-
2519
//allows JSON data in request body to be parsed
2620
app.use(express.json())
2721
// allow URL-encoded data in request body to be parsed

user_service/src/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@ import express from 'express';
22
import userRouter from './routes/userRoutes';
33
import cookieParser from 'cookie-parser'
44
import authRouter from './routes/authRoutes'
5-
import { Request } from "express";
6-
import cors from "cors";
75
import { setupAdminUser } from './config/initialSetup';
86

97
const app = express();
108
const PORT = process.env.PORT || 8081;
11-
const corsOptions = {
12-
origin: 'http://localhost:3000', //TODO: need to add our production url here once we host it. Currently assuming all requests will be made from this url
13-
credentials: true, //access-control-allow-credentials:true
14-
optionSuccessStatus: 200
15-
}
169

1710

1811
app.use(cookieParser());
19-
app.use(cors<Request>(corsOptions));
2012
app.use(express.json());
2113

2214
app.use('/api/users', userRouter);

0 commit comments

Comments
 (0)