Skip to content

Commit 8d0c3be

Browse files
climba03003Uzlopakgurgunday
authored
fix: allow fallback to fastify route config (#410)
* fix: allow fallback to [email protected] route config * Apply suggestions from code review Co-authored-by: Gürgün Dayıoğlu <[email protected]> --------- Co-authored-by: Uzlopak <[email protected]> Co-authored-by: Gürgün Dayıoğlu <[email protected]>
1 parent 2471a4c commit 8d0c3be

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ async function fastifyStatic (fastify, opts) {
396396
}
397397

398398
function serveFileHandler (req, reply) {
399-
const routeConfig = req.routeOptions.config
399+
// TODO: remove the fallback branch when bump major
400+
/* istanbul ignore next */
401+
const routeConfig = req.routeOptions?.config || req.routeConfig
400402
pumpSendToReply(req, reply, routeConfig.file, routeConfig.rootPath)
401403
}
402404
}
@@ -552,7 +554,7 @@ function getRedirectUrl (url) {
552554
}
553555

554556
module.exports = fp(fastifyStatic, {
555-
fastify: '^4.23.0',
557+
fastify: '4.x',
556558
name: '@fastify/static'
557559
})
558560
module.exports.default = fastifyStatic

0 commit comments

Comments
 (0)