Skip to content

Commit 13b37df

Browse files
committed
feat: enable OPTIONS middleware by default
1 parent c373320 commit 13b37df

File tree

3 files changed

+10
-42
lines changed

3 files changed

+10
-42
lines changed

lib/Server.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,8 @@ class Server {
21312131
middleware: this.setHeaders.bind(this),
21322132
});
21332133
}
2134-
if (this.options.optionsMethod) {
2134+
2135+
{
21352136
/**
21362137
*
21372138
* @param {Request} req
@@ -2151,7 +2152,7 @@ class Server {
21512152
};
21522153

21532154
middlewares.push({
2154-
name: "options-request-response",
2155+
name: "options-middleware",
21552156
path: "*",
21562157
middleware: optionsRequestResponseMiddleware,
21572158
});

lib/options.json

-10
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,6 @@
458458
"description": "Allows to set custom headers on response.",
459459
"link": "https://webpack.js.org/configuration/dev-server/#devserverheaders"
460460
},
461-
"OptionsMethod": {
462-
"type": "boolean",
463-
"description": "Response with 204 httpCode when receive an OPTIONS request",
464-
"cli": {
465-
"exclude": true
466-
}
467-
},
468461
"HistoryApiFallback": {
469462
"anyOf": [
470463
{
@@ -1178,9 +1171,6 @@
11781171
"headers": {
11791172
"$ref": "#/definitions/Headers"
11801173
},
1181-
"optionsMethod": {
1182-
"$ref": "#/definitions/OptionsMethod"
1183-
},
11841174
"historyApiFallback": {
11851175
"$ref": "#/definitions/HistoryApiFallback"
11861176
},

types/lib/Server.d.ts

+7-30
Original file line numberDiff line numberDiff line change
@@ -2217,17 +2217,11 @@ declare class Server {
22172217
description: string;
22182218
link: string;
22192219
};
2220-
OptionsMethod: {
2221-
type: string;
2222-
description: string;
2223-
cli: {
2224-
exclude: boolean;
2225-
};
2226-
};
22272220
HistoryApiFallback: {
22282221
anyOf: (
22292222
| {
22302223
type: string;
2224+
/** @type {ClientConfiguration} */
22312225
cli: {
22322226
negatedDescription: string;
22332227
};
@@ -2236,7 +2230,6 @@ declare class Server {
22362230
}
22372231
| {
22382232
type: string;
2239-
/** @type {string} */
22402233
description: string;
22412234
link: string;
22422235
cli?: undefined /** @typedef {import("express").Request} Request */;
@@ -2301,7 +2294,7 @@ declare class Server {
23012294
cli: {
23022295
negatedDescription: string;
23032296
};
2304-
/** @type {number | string} */ link: string;
2297+
link: string;
23052298
};
23062299
MagicHTML: {
23072300
type: string;
@@ -2456,7 +2449,6 @@ declare class Server {
24562449
Proxy: {
24572450
anyOf: (
24582451
| {
2459-
/** @type {any} */
24602452
type: string;
24612453
items?: undefined;
24622454
}
@@ -2476,7 +2468,7 @@ declare class Server {
24762468
};
24772469
}
24782470
)[];
2479-
description: string;
2471+
/** @type {any} */ description: string;
24802472
link: string;
24812473
};
24822474
Server: {
@@ -2486,7 +2478,6 @@ declare class Server {
24862478
link: string;
24872479
description: string;
24882480
};
2489-
/** @type {MultiCompiler} */
24902481
ServerType: {
24912482
enum: string[];
24922483
};
@@ -2637,10 +2628,6 @@ declare class Server {
26372628
}
26382629
| {
26392630
instanceof: string;
2640-
/**
2641-
* @param {string | Static | undefined} [optionsForStatic]
2642-
* @returns {NormalizedStatic}
2643-
*/
26442631
type?: undefined;
26452632
}
26462633
)[];
@@ -2930,7 +2917,7 @@ declare class Server {
29302917
| {
29312918
enum: boolean[];
29322919
cli: {
2933-
negatedDescription: string /** @type {Array<keyof ServerOptions>} */;
2920+
negatedDescription: string;
29342921
};
29352922
$ref?: undefined;
29362923
}
@@ -2962,20 +2949,13 @@ declare class Server {
29622949
exclude: boolean;
29632950
};
29642951
};
2965-
/**
2966-
* @param {string | Buffer | undefined} item
2967-
* @returns {string | Buffer | undefined}
2968-
*/
29692952
};
2970-
/**
2971-
* @param {string | Buffer | undefined} item
2972-
* @returns {string | Buffer | undefined}
2973-
*/
29742953
additionalProperties: boolean;
29752954
};
2955+
/** @type {any} */
29762956
WebSocketServerString: {
29772957
type: string;
2978-
minLength: number;
2958+
/** @type {ServerOptions} */ minLength: number;
29792959
};
29802960
};
29812961
additionalProperties: boolean;
@@ -2998,9 +2978,6 @@ declare class Server {
29982978
headers: {
29992979
$ref: string;
30002980
};
3001-
optionsMethod: {
3002-
$ref: string;
3003-
};
30042981
historyApiFallback: {
30052982
$ref: string;
30062983
};
@@ -3023,7 +3000,7 @@ declare class Server {
30233000
$ref: string;
30243001
};
30253002
magicHtml: {
3026-
$ref: string;
3003+
$ref: string /** @type {ServerOptions} */;
30273004
};
30283005
onAfterSetupMiddleware: {
30293006
$ref: string;

0 commit comments

Comments
 (0)