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 13b37df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 42 deletions.
5 changes: 3 additions & 2 deletions lib/Server.js
Expand Up @@ -2131,7 +2131,8 @@ class Server {
middleware: this.setHeaders.bind(this),
});
}
if (this.options.optionsMethod) {

{
/**
*
* @param {Request} req
Expand All @@ -2151,7 +2152,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
37 changes: 7 additions & 30 deletions types/lib/Server.d.ts
Expand Up @@ -2217,17 +2217,11 @@ declare class Server {
description: string;
link: string;
};
OptionsMethod: {
type: string;
description: string;
cli: {
exclude: boolean;
};
};
HistoryApiFallback: {
anyOf: (
| {
type: string;
/** @type {ClientConfiguration} */
cli: {
negatedDescription: string;
};
Expand All @@ -2236,7 +2230,6 @@ declare class Server {
}
| {
type: string;
/** @type {string} */
description: string;
link: string;
cli?: undefined /** @typedef {import("express").Request} Request */;
Expand Down Expand Up @@ -2301,7 +2294,7 @@ declare class Server {
cli: {
negatedDescription: string;
};
/** @type {number | string} */ link: string;
link: string;
};
MagicHTML: {
type: string;
Expand Down Expand Up @@ -2456,7 +2449,6 @@ declare class Server {
Proxy: {
anyOf: (
| {
/** @type {any} */
type: string;
items?: undefined;
}
Expand All @@ -2476,7 +2468,7 @@ declare class Server {
};
}
)[];
description: string;
/** @type {any} */ description: string;
link: string;
};
Server: {
Expand All @@ -2486,7 +2478,6 @@ declare class Server {
link: string;
description: string;
};
/** @type {MultiCompiler} */
ServerType: {
enum: string[];
};
Expand Down Expand Up @@ -2637,10 +2628,6 @@ declare class Server {
}
| {
instanceof: string;
/**
* @param {string | Static | undefined} [optionsForStatic]
* @returns {NormalizedStatic}
*/
type?: undefined;
}
)[];
Expand Down Expand Up @@ -2930,7 +2917,7 @@ declare class Server {
| {
enum: boolean[];
cli: {
negatedDescription: string /** @type {Array<keyof ServerOptions>} */;
negatedDescription: string;
};
$ref?: undefined;
}
Expand Down Expand Up @@ -2962,20 +2949,13 @@ declare class Server {
exclude: boolean;
};
};
/**
* @param {string | Buffer | undefined} item
* @returns {string | Buffer | undefined}
*/
};
/**
* @param {string | Buffer | undefined} item
* @returns {string | Buffer | undefined}
*/
additionalProperties: boolean;
};
/** @type {any} */
WebSocketServerString: {
type: string;
minLength: number;
/** @type {ServerOptions} */ minLength: number;
};
};
additionalProperties: boolean;
Expand All @@ -2998,9 +2978,6 @@ declare class Server {
headers: {
$ref: string;
};
optionsMethod: {
$ref: string;
};
historyApiFallback: {
$ref: string;
};
Expand All @@ -3023,7 +3000,7 @@ declare class Server {
$ref: string;
};
magicHtml: {
$ref: string;
$ref: string /** @type {ServerOptions} */;
};
onAfterSetupMiddleware: {
$ref: string;
Expand Down

0 comments on commit 13b37df

Please sign in to comment.