Skip to content

Commit da16ee5

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

File tree

4 files changed

+55
-85
lines changed

4 files changed

+55
-85
lines changed

lib/Server.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ const schema = require("./options.json");
199199
* @property {boolean} [setupExitSignals]
200200
* @property {boolean | ClientConfiguration} [client]
201201
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
202-
* @property {boolean} [optionsMethod]
203202
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
204203
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
205204
* @property {(devServer: Server) => void} [onListening]
@@ -2131,7 +2130,8 @@ class Server {
21312130
middleware: this.setHeaders.bind(this),
21322131
});
21332132
}
2134-
if (this.options.optionsMethod) {
2133+
2134+
{
21352135
/**
21362136
*
21372137
* @param {Request} req
@@ -2151,7 +2151,7 @@ class Server {
21512151
};
21522152

21532153
middlewares.push({
2154-
name: "options-request-response",
2154+
name: "options-middleware",
21552155
path: "*",
21562156
middleware: optionsRequestResponseMiddleware,
21572157
});

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
},

test/e2e/options-request-response.test.js renamed to test/e2e/options-middleware.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ describe("handle options-request correctly", () => {
5050
"Access-Control-Allow-Origin": "*",
5151
"Access-Control-Allow-Headers": "*",
5252
},
53-
optionsMethod: true,
5453
},
5554
compiler
5655
);

0 commit comments

Comments
 (0)