Skip to content

Commit bac8b15

Browse files
committed
chore: CORS should be disabled by default
The default security posture disallows CORS and cookie transfers between domains. that is much more stricter than allowing CORS. CORS should only be enabled on a need by basis.
1 parent 5ff150a commit bac8b15

File tree

3 files changed

+0
-77
lines changed

3 files changed

+0
-77
lines changed

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"dependencies": {
6565
"@aicore/libcommonutils": "1.0.20",
6666
"@fastify/compress": "^8.0.1",
67-
"@fastify/cors": "^10.0.2",
6867
"@fastify/rate-limit": "^10.2.2",
6968
"@fastify/static": "8.1.0",
7069
"fastify": "5.2.1",

src/server.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {getConfigs} from "./utils/configs.js";
1010
import {getHelloSchema, hello, getHelloPostSchema, helloPost} from "./api/hello.js";
1111
import {fastifyStatic} from "@fastify/static";
1212
import rateLimit from '@fastify/rate-limit';
13-
import cors from '@fastify/cors';
1413
import compression from '@fastify/compress';
1514

1615
import path from 'path';
@@ -55,23 +54,6 @@ server.register(rateLimit, {
5554
}
5655
});
5756

58-
server.register(cors, {
59-
origin: process.env.NODE_ENV === 'production'
60-
? ['https://yourdomain.com']
61-
: true,
62-
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
63-
allowedHeaders: [
64-
'Content-Type',
65-
'Authorization',
66-
'X-Requested-With',
67-
'Accept'
68-
],
69-
exposedHeaders: ['Content-Range', 'X-Content-Range'],
70-
credentials: true,
71-
maxAge: 86400,
72-
preflight: true
73-
});
74-
7557
// Response Sanitization
7658
function sanitizeResponse(data) {
7759
const sensitiveFields = ['password', 'token', 'secret', 'key', 'auth'];

0 commit comments

Comments
 (0)