Skip to content

Allowing using middleware config in dev server options #32811

@tianma630

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions