Skip to content

Commit c0c5b1e

Browse files
authored
chore: update migration guide (fastify CORS)
1 parent a278b12 commit c0c5b1e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

content/migration.md

+22
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ bootstrap();
9090

9191
> info **Hint** There have been no changes to path matching in Fastify v5 (except for middleware, see the section below), so you can continue using the wildcard syntax as you did before. The behavior remains the same, and routes defined with wildcards (like `*`) will still work as expected.
9292
93+
#### Fastify CORS
94+
95+
> warning **Warning** Allowed HTTP methods have changed to the [CORS-safelisted methods](https://fetch.spec.whatwg.org/#methods) by default. To allow other methods (e.g., `PUT`, `PATCH`, `DELETE`), you must explicitly specify them in the `methods` option.
96+
97+
```typescript
98+
const methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']; // OR comma-delimited string 'GET,POST,PUT,PATH,DELETE'
99+
100+
const app = await NestFactory.create<NestFastifyApplication>(
101+
AppModule,
102+
new FastifyAdapter(),
103+
{ cors: { methods }}
104+
);
105+
106+
// OR
107+
108+
const app = await NestFactory.create<NestFastifyApplication>(
109+
AppModule,
110+
new FastifyAdapter()
111+
);
112+
app.enableCors({ methods );
113+
```
114+
93115
#### Fastify middleware registration
94116
95117
NestJS 11 now uses the latest version of the [path-to-regexp](https://www.npmjs.com/package/path-to-regexp) package to match **middleware paths** in `@nestjs/platform-fastify`. As a result, the `(.*)` syntax for matching all paths is no longer supported. Instead, you should use named wildcards.

0 commit comments

Comments
 (0)