Skip to content

Commit f388421

Browse files
fix(platform-fastify): fallback to (.*) in middleware factory
1 parent 329b083 commit f388421

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/platform-fastify/adapters/fastify-adapter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
CorsOptionsDelegate,
1313
} from '@nestjs/common/interfaces/external/cors-options.interface';
1414
import { loadPackage } from '@nestjs/common/utils/load-package.util';
15-
import { isUndefined, isString } from '@nestjs/common/utils/shared.utils';
15+
import { isString, isUndefined } from '@nestjs/common/utils/shared.utils';
1616
import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter';
1717
import {
1818
fastify,
@@ -422,10 +422,13 @@ export class FastifyAdapter<
422422
await this.registerMiddie();
423423
}
424424
return (path: string, callback: Function) => {
425-
const normalizedPath = path.endsWith('/*')
425+
let normalizedPath = path.endsWith('/*')
426426
? `${path.slice(0, -1)}(.*)`
427427
: path;
428428

429+
// Fallback to "(.*)" to support plugins like GraphQL
430+
normalizedPath = normalizedPath === '/(.*)' ? '(.*)' : normalizedPath;
431+
429432
// The following type assertion is valid as we use import('middie') rather than require('middie')
430433
// ref https://github.com/fastify/middie/pull/55
431434
this.instance.use(

0 commit comments

Comments
 (0)