@xenterprises/fastify-xconfig 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xenterprises/fastify-xconfig",
3
3
  "type": "module",
4
- "version": "1.1.7",
4
+ "version": "1.1.8",
5
5
  "description": "Fastify configuration plugin for setting up middleware, services, and route handling.",
6
6
  "main": "src/xConfig.js",
7
7
  "scripts": {
@@ -1,10 +1,14 @@
1
1
  export async function setupCors(fastify, options) {
2
2
  if (options.active !== false) {
3
+ // Extract active flag and pass all other options directly to the CORS plugin
4
+ const { active, ...corsOptions } = options;
5
+
3
6
  await fastify.register(await import("@fastify/cors"), {
4
- origin: options.origin || ["https://getx.io", "http://localhost:3000"],
5
- credentials: options.credentials !== undefined ? options.credentials : true,
6
- methods: options.methods || ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
7
+ origin: corsOptions.origin || ["https://getx.io", "http://localhost:3000"],
8
+ credentials: corsOptions.credentials !== undefined ? corsOptions.credentials : true,
9
+ methods: corsOptions.methods || ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
10
+ ...corsOptions // This will include ignorePaths: ['/public'] in the preflight config
7
11
  });
8
12
  console.info(" ✅ CORS Enabled");
9
13
  }
10
- }
14
+ }