Skip to content

Commit ec57c55

Browse files
committed
feat(backend): allow CORS
1 parent 10e9e23 commit ec57c55

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

backend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "backend",
33
"module": "src/index.ts",
44
"type": "module",
5-
"version": "0.0.1",
5+
"version": "0.0.1",
66
"private": true,
77
"scripts": {
88
"dev": "bun --hot run src/index.ts",
@@ -12,7 +12,9 @@
1212
"opt:proxy": "HTTP_PROXY=http://127.0.0.1:8080 HTTPS_PROXY=http://127.0.0.1:8080"
1313
},
1414
"dependencies": {
15+
"@types/cors": "^2.8.19",
1516
"@types/express": "^5.0.3",
17+
"cors": "^2.8.5",
1618
"express": "^5.1.0",
1719
"lru-cache": "^11.1.0",
1820
"mclib": "workspace:*"

backend/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import express from 'express';
22
import type { Request, Response as ExpressResponse, NextFunction } from 'express';
3+
import cors from 'cors';
34

45
import { cache, TTL } from './cache'
56
import { router } from './modsEndpoints'
@@ -30,9 +31,9 @@ function loggerMiddleware(req: Request, res: ExpressResponse, next: NextFunction
3031
next();
3132
}
3233

33-
// Middleware to parse JSON bodies
34-
app.use(express.json());
35-
app.use(loggerMiddleware);
34+
app.use(express.json()); // Parse JSON bodies
35+
app.use(loggerMiddleware); // Log
36+
app.use(cors()); // Enable CORS
3637

3738
// Logic routes
3839
app.use('/', router);

bun.lock

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

0 commit comments

Comments
 (0)