Skip to content

Commit da8ae32

Browse files
authored
feat(server)!: improve default options for CORSPlugin (#143)
Use default * for allow origin can security risk in some cases
1 parent 0c47447 commit da8ae32

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

packages/server/src/plugins/cors.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ export class CORSPlugin<TContext extends Context> implements Plugin<TContext> {
1818

1919
constructor(options?: Partial<CORSOptions<TContext>>) {
2020
const defaults: CORSOptions<TContext> = {
21-
origin: '*',
21+
origin: origin => origin,
2222
allowMethods: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH'],
2323
}
2424

25-
if (options?.credentials) {
26-
defaults.origin = origin => origin
27-
}
28-
2925
this.options = {
3026
...defaults,
3127
...options,

0 commit comments

Comments
 (0)