angular / angular/angular-cli

Allowing using middleware config in dev server options

未关闭
#32,811 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
angular/build:dev-server area: @angular/build gemini-triaged
主要语言
TypeScript
星标
27k
派生
11.8k
平均合并
14 小时 23 分钟
30 天内合并 PR
162

描述

### 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_

贡献指南

打开贡献指南

调研方向

Start by tracing the serve command's dev-server options and the existing proxyConfig implementation, then inspect how angular.json server options are parsed and how angular/build injects development-server configuration. Done means middlewareConfig accepts a JavaScript file exporting one middleware function or an array, and the configured middleware runs in the dev server.

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
build-system, cli
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。