Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const noop = () => {};
* @property {boolean=} lastModified options to generate last modified header
* @property {(boolean | number | string | { maxAge?: number, immutable?: boolean })=} cacheControl options to generate cache headers
* @property {boolean=} cacheImmutable is cache immutable
* @property {boolean=} forwardError forward error to next middleware
*/

/**
Expand Down
5 changes: 2 additions & 3 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ function wrapper(context) {
}

const acceptedMethods = context.options.methods || ["GET", "HEAD"];
// TODO do we need an option here?
const forwardError = false;

initState(res);

Expand All @@ -180,13 +178,14 @@ function wrapper(context) {
* @returns {Promise<void>}
*/
async function sendError(message, status, options) {
if (forwardError) {
if (context.options.forwardError) {
const error =
/** @type {Error & { statusCode: number }} */
(new Error(message));
error.statusCode = status;

await goNext(error);
return;
Comment thread
bjohansebas marked this conversation as resolved.
}

const escapeHtml = getEscapeHtml();
Expand Down
5 changes: 5 additions & 0 deletions src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
"description": "Enable or disable setting `Cache-Control: public, max-age=31536000, immutable` response header for immutable assets (i.e. asset with a hash in file name like `image.a4c12bde.jpg`).",
"link": "https://github.com/webpack/webpack-dev-middleware#cacheimmutable",
"type": "boolean"
},
"forwardError": {
"description": "Enable or disable forwarding errors to next middleware.",
"link": "https://github.com/webpack/webpack-dev-middleware#forwarderrors",
"type": "boolean"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add this to our README too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep!

}
},
"additionalProperties": false
Expand Down
Loading