Skip to content
Advertisement

Fastify: Ommit some APIs from using basic authentication

Currently, I have two APIs: /auth and /no-auth.

I would like ONLY one of them to use basic-auth.

I am using fastify-basic-auth plugin on top of fastify in node.

/auth should require authentication.

/no-auth should NOT require authentication.

Currently, the way my code is set up, BOTH are requiring authentication.

JavaScript

Advertisement

Answer

To archive it you need to create a new encapsulated context calling register:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement