You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.22.2
Plugin version
4.5.1
Node.js version
18.7
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
20.04
Description
Using autoload & autohooks.js inside a folder, when defining setNotFoundHandler inside autohooks.js, & defining prefix on the autoload options, the defined setNotFoundHandler leaks outside of the prefix.
// plugins/routes.tsexportconstroutesPlugin: FastifyPluginCallback=asyncfunctionroutesPlugin(instance){instance.route(rendererRoute);instance.register(autoload,{dir: path.join(__dirname,'../routes/api'),forceESM: true,autoHooks: true,cascadeHooks: true,options: {prefix: env.API_PATH},// this is the autoload prefix its value is `/api`});};
When calling to /api/not-exists it shows the ActionNotFound error (as expected)
but, when calling /not-exists it also shows the ActionNotFound error, evenough, the not found handler is defined inside the prefix /api.
I've tried even to add encapsulate: true to autoload options, without luck.
Expected Behavior
From Fastify docs, it specifies that if there is a prefix defined, setNotFoundHandler should be encapsulated to this prefix.
AutoLoad should enforce the same thing.
The text was updated successfully, but these errors were encountered:
Prerequisites
Fastify version
4.22.2
Plugin version
4.5.1
Node.js version
18.7
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
20.04
Description
Using autoload &
autohooks.js
inside a folder, when definingsetNotFoundHandler
insideautohooks.js
, & definingprefix
on the autoload options, the definedsetNotFoundHandler
leaks outside of theprefix
.Steps to Reproduce
Assume the following folder structure.
When calling to
/api/not-exists
it shows theActionNotFound
error (as expected)but, when calling
/not-exists
it also shows theActionNotFound
error, evenough, the not found handler is defined inside the prefix/api
.I've tried even to add
encapsulate: true
to autoload options, without luck.Expected Behavior
From Fastify docs, it specifies that if there is a
prefix
defined,setNotFoundHandler
should be encapsulated to this prefix.AutoLoad should enforce the same thing.
The text was updated successfully, but these errors were encountered: