0

I am facing an weird issue. In my swagger doc, I am always seeing default OPTIONS API is getting listed without any specification from my routes.

I am registering fastify-cors which seems the issue.

fastify.register(require('fastify-cors'), {});
fastify.register(require('./routes/routes'));

This is the screen shot:

enter image description here

My versions are:

    "fastify": "^3.19.0",
    "fastify-auth0-verify": "^0.5.2",
    "fastify-cors": "^6.0.1",
    "fastify-swagger": "^4.8.2",
    "fastify-mongodb": "^2.0.1",
    "mongo-sanitize": "^1.1.0"

What's the way out? It looks really odd as my swagger is going to be out for our customers/integrators.

Thanks, Pradip

Pradip
  • 509
  • 1
  • 5
  • 22

1 Answers1

2

That route is the preflight route handler.

To skip it you must disable it:

fastify.register(require('fastify-cors'), {
  preflight: false
});

Or simply hide it:

fastify.register(require('fastify-cors'), {
  hideOptionsRoute: true
})
Manuel Spigolon
  • 11,003
  • 5
  • 50
  • 73