Skip to content

Commit aa253f5

Browse files
committed
feat: update CORS configuration to allow all origins and methods
1 parent 68342e2 commit aa253f5

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

dist/index.cjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ function _init() {
136136
* Register cors plugin
137137
************************************/
138138
if (!((_config$app = config.app) !== null && _config$app !== void 0 && _config$app.disableCors)) {
139-
fastifyInstance.register(_cors["default"]);
139+
fastifyInstance.register(_cors["default"], {
140+
origin: true,
141+
methods: ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'PATCH'],
142+
allowedHeaders: '*',
143+
credentials: true,
144+
maxAge: 86400
145+
});
140146
}
141147

142148
/************************************

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fastify-app",
3-
"version": "2.0.5",
3+
"version": "2.0.6",
44
"description": "A simple fastify app template for JSON API server with helpful routes and initial settings.",
55
"main": "src/index.mjs",
66
"module": "src/index.mjs",

src/index.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ async function init(config) {
8989
* Register cors plugin
9090
************************************/
9191
if (!config.app?.disableCors) {
92-
fastifyInstance.register(cors);
92+
fastifyInstance.register(cors, {
93+
origin: true,
94+
methods: ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'PATCH'],
95+
allowedHeaders: '*',
96+
credentials: true,
97+
maxAge: 86400,
98+
});
9399
}
94100

95101
/************************************

0 commit comments

Comments
 (0)