Skip to content

Commit

Permalink
feat: enable OPTIONS middleware by default
Browse files Browse the repository at this point in the history
  • Loading branch information
TrickyPi committed Jul 30, 2022
1 parent c373320 commit da16ee5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 85 deletions.
6 changes: 3 additions & 3 deletions lib/Server.js
Expand Up @@ -199,7 +199,6 @@ const schema = require("./options.json");
* @property {boolean} [setupExitSignals]
* @property {boolean | ClientConfiguration} [client]
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
* @property {boolean} [optionsMethod]
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
* @property {(devServer: Server) => void} [onListening]
Expand Down Expand Up @@ -2131,7 +2130,8 @@ class Server {
middleware: this.setHeaders.bind(this),
});
}
if (this.options.optionsMethod) {

{
/**
*
* @param {Request} req
Expand All @@ -2151,7 +2151,7 @@ class Server {
};

middlewares.push({
name: "options-request-response",
name: "options-middleware",
path: "*",
middleware: optionsRequestResponseMiddleware,
});
Expand Down
10 changes: 0 additions & 10 deletions lib/options.json
Expand Up @@ -458,13 +458,6 @@
"description": "Allows to set custom headers on response.",
"link": "https://webpack.js.org/configuration/dev-server/#devserverheaders"
},
"OptionsMethod": {
"type": "boolean",
"description": "Response with 204 httpCode when receive an OPTIONS request",
"cli": {
"exclude": true
}
},
"HistoryApiFallback": {
"anyOf": [
{
Expand Down Expand Up @@ -1178,9 +1171,6 @@
"headers": {
"$ref": "#/definitions/Headers"
},
"optionsMethod": {
"$ref": "#/definitions/OptionsMethod"
},
"historyApiFallback": {
"$ref": "#/definitions/HistoryApiFallback"
},
Expand Down
Expand Up @@ -50,7 +50,6 @@ describe("handle options-request correctly", () => {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
},
optionsMethod: true,
},
compiler
);
Expand Down

0 comments on commit da16ee5

Please sign in to comment.