Rewriting req.url in router with prefix path results in missing slash (/)
维护者通常 1 天内回复
@sarthak0906 已经在做这个了。
开始于 2020年3月7日。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- express, javascript, node.js
调研方向
先从 bug.js 中展示的 router 和挂载路径行为开始,然后运行 node bug.js 和 curl localhost:3000/app,以复现缺少斜杠的问题。跟踪 express.Router 和 app.use('/app', router) 如何重新挂载重写后的 req.url;当记录的路径为 /app/index.html 时即完成。
由索引模型根据 Issue 内容生成。
描述
Hello, I've been trying to use a npm module (connect-history-api-fallback) and encounter problems that after a lot of debugging I believe boils down to this issue.
When you're in a router that has a mount path, doing a rewrite on the relative root ('') path result in a missing slash, eg with bug.js as below
const express = require('express')
const app = express()
const port = 3000
var router = express.Router();
router.get('/', function (req, res, next) {
req.url = "/index.html"
next()
});
app.use('/app', router);
app.use(function (req, res, next) {
console.log("Rewritten path: " + req.url)
res.end()
});
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
Running the following commands:
node bug.js
curl localhost:3000/app
results in the rewritten path to be /appindex.html instead of /app/index.html
Environment:
"node": 12.10.0
"express": 4.17.1
This sounds like a bug to me, but maybe I'm doing something wrong? I'm not too expert in expressjs to know for sure (my hunch is the router code doesn't 'remount' the prefix path properly.
Thanks!
- 主要语言
- JavaScript
- 星标
- 69.7k
- 派生
- 25.6k
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
expressjs/express 的其他 Issue
-
Outdated res.send() syntax in lib/response.js documentation example可能重新可做 关联的 PR 已关闭且未合并。 未关闭docs
难度 1/5 1 小时以内 新手友好度 95/100
expressjs/express#7588 · 1 条评论 ·
维护者通常 1 天内回复
-
4.x deps module:body-parser
难度 1/5 1 小时以内 新手友好度 75/100
expressjs/express#7564 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Update to mocha 12.x可能已有人在做 @ganeshghutukade-04 于 26 天前认领。 未关闭deps
难度 2/5 1-3 小时 新手友好度 67/100
expressjs/express#7547 · 6 条评论 ·
维护者通常 1 天内回复
-
req.subdomains splits an IPv6 host that contains dots可能已有人在做 @johnnyhuirilef 于 30 天前认领。 未关闭4.x 5.x bug
难度 2/5 1-3 小时 新手友好度 72/100
expressjs/express#7532 · 2 条评论 ·
维护者通常 1 天内回复
-
Readme: project name 'express.js' is not capitalized可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 1/5 1 小时以内 新手友好度 95/100
维护者通常 1 天内回复
查看 expressjs/express 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
ipfs/ipfs-webui#2507 ·
-
Environments table lists page size 5 after 30可能已有人在做 @raus7n 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
litmuschaos/litmus#5743 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 63/100
anothaDev/luci-theme-vantage#143 ·
维护者通常 1 天内回复
-
desktop grp:admin-donors type:graphics-bug ui-admin
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
kingcharleslzy-ai/dsh-purge#282 ·
维护者通常 1 天内回复