webpack / webpack/webpack-dev-server

behavior of static and historyApiFallback

Open
#2,716 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

scope: server semver: patch severity: 5 (confusing) type: feature type: refactor
Dominant language
JavaScript
Stars
7.8k
Forks
1.5k
Avg merge
5h 32m
Merged PRs (30d)
6

Description

Expected Behavior

Static serving middleware for the dev server should only need to be applied to the express server once via this.app.use(...)

Actual Behavior

static middleware is applied to the express server multiple times in order to make historyApiFallback work as expected. This is explained here: https://github.com/webpack/webpack-dev-server/pull/2670#discussion_r464946541

A similar thing seems to have been added for the middleware feature as seen here, as it is added multiple times:

https://github.com/webpack/webpack-dev-server/blob/4ab1f21bc85cc1695255c739160ad00dc14375f1/lib/Server.js#L548-L559

Solution

We need to find a way to either apply all of this middleware once without having any breaking changes, or have intentional slight breaking changes while only applying the middleware once. We should also look into if applying the same middleware many times causes performance losses, or if it is an acceptable thing to do.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the linked discussion on pull request 2670 and inspect lib/Server.js around lines 548–559, where the middleware feature is added. Then trace how static serving and historyApiFallback are configured and consider the compatibility and performance tradeoffs described in the issue. Done means identifying a way to apply middleware once, or documenting an intentional breaking change and its implications.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript, webpack
Domain
backend, devtools
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.