Skip to content

Commit 4603279

Browse files
committed
fix(app): only apply cache rules ro routes (not middleware)
1 parent e9285da commit 4603279

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/runtime/app.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,17 @@ function createNitroApp (): NitroApp {
3838

3939
for (const h of handlers) {
4040
let handler = h.lazy ? lazyEventHandler(h.handler) : h.handler
41-
42-
// Wrap matching handlers for caching route options
43-
const routeRules = getRouteRulesForPath(h.route.replace(/:\w+|\*\*/g, '_'))
44-
if (routeRules.cache) {
45-
handler = cachedEventHandler(handler, {
46-
group: 'nitro/routes',
47-
...routeRules.cache
48-
})
49-
}
50-
5141
if (h.middleware || !h.route) {
5242
const middlewareBase = (config.app.baseURL + (h.route || '/')).replace(/\/+/g, '/')
5343
h3App.use(middlewareBase, handler)
5444
} else {
45+
const routeRules = getRouteRulesForPath(h.route.replace(/:\w+|\*\*/g, '_'))
46+
if (routeRules.cache) {
47+
handler = cachedEventHandler(handler, {
48+
group: 'nitro/routes',
49+
...routeRules.cache
50+
})
51+
}
5552
router.use(h.route, handler, h.method)
5653
}
5754
}

0 commit comments

Comments
 (0)