Skip to content

Allowing using middleware config in dev server options #32811

Description

@tianma630

Command

serve

Description

Dev server middleware configuration is very commonly used in development,such as auto login or log printing,but it is not currently supported。

Describe the solution you'd like

Refer to the implementation of proxyConfig, add the middlewareConfig configuration to angular.json -> server -> options, and parse and inject the middleware in angular/build.
middlewareConfig supports configuring a js file path, and the file exports a single middleware function or an array of multipe middleware functions. such as:

function log(req, res, next) {
    next()
}

module.exports  = log;
function log(req, res, next) {
    next()
}

function auth(req, res, next) {
    next()
}

module.exports =
    [
        log,
        auth,
    ]

Describe alternatives you've considered

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions