Skip to content

Commit bbad042

Browse files
committed
Fix cors options
1 parent 9132a02 commit bbad042

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

api_gateway/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api_gateway/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
},
2424
"devDependencies": {
2525
"@types/cookie-parser": "^1.4.5",
26+
"@types/cors": "^2.8.16",
2627
"@types/express": "^4.17.20",
2728
"@types/express-jwt": "^7.4.2",
2829
"@types/morgan": "^1.9.7",

api_gateway/src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { routes_config, ws_collab_proxy_config, ws_match_proxy_config } from './
55
import { jwtCheck, onCredentialFailure } from './middleware/token_check';
66
import { setupLogging } from './middleware/logging';
77
import { isLocal } from './proxy/service_addresses';
8-
import { createProxyMiddleware } from 'http-proxy-middleware';
8+
import cors from 'cors';
9+
10+
const corsOptions = {
11+
origin: ["http://peerprep-g10.com", "https://peerprep-g10.com", "http://localhost:3000"],
12+
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
13+
}
14+
915

1016
const httpApp = express();
1117
const httpProxyPort: number = parseInt(process.env.PORT || "8000");
@@ -16,6 +22,10 @@ const wsMatchMakePort : number = parseInt(process.env.PORT || "7999");
1622
const wsCollabApp = express();
1723
const wsCollabAppPort : number = parseInt(process.env.PORT || "7998");
1824

25+
httpApp.use(cors(corsOptions));
26+
wsMatchMakeApp.use(cors(corsOptions));
27+
wsCollabApp.use(cors(corsOptions));
28+
1929

2030
httpApp.use(cookieParser())
2131

0 commit comments

Comments
 (0)