Skip to content

Commit 6976ffe

Browse files
bugfix(@nestjs/core) middleware wildcard is not working with fastify
1 parent 62e733c commit 6976ffe

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/core/adapters/fastify-adapter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ export class FastifyAdapter {
137137
): (path: string, callback: Function) => any {
138138
return (path: string, callback: Function) => {
139139
const re = pathToRegexp(path);
140-
this.instance.use(path, (req, res, next) => {
140+
const normalizedPath = path === '/*' ? '' : path;
141+
142+
this.instance.use(normalizedPath, (req, res, next) => {
141143
if (!re.exec(req.originalUrl + '/')) {
142144
return next();
143145
}

packages/core/router/router-explorer.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ import { RouteParamsFactory } from './route-params-factory';
2222
import { RouterExecutionContext } from './router-execution-context';
2323
import { RouterProxy, RouterProxyCallback } from './router-proxy';
2424

25+
export interface RoutePathProperties {
26+
path: string;
27+
requestMethod: RequestMethod;
28+
targetCallback: RouterProxyCallback;
29+
methodName: string;
30+
}
31+
2532
export class RouterExplorer {
2633
private readonly executionContextCreator: RouterExecutionContext;
2734
private readonly routerMethodFactory = new RouterMethodFactory();
@@ -180,10 +187,3 @@ export class RouterExplorer {
180187
return this.routerProxy.createProxy(executionContext, exceptionFilter);
181188
}
182189
}
183-
184-
export interface RoutePathProperties {
185-
path: string;
186-
requestMethod: RequestMethod;
187-
targetCallback: RouterProxyCallback;
188-
methodName: string;
189-
}

0 commit comments

Comments
 (0)