Node.js 未找到节点快速投递路线中的括号
我在模拟Express中的POST route以测试MS XRM 工作路线:Node.js 未找到节点快速投递路线中的括号,node.js,express,Node.js,Express,我在模拟Express中的POST route以测试MS XRM 工作路线: http://localhost:3000/api/data/v8.0/something app.post('/api/data/v8.0/something', function (req, res) { res.send({data:'1234A'}); }); http://localhost:3000/api/data/v8.0/something(ABC)/somethingelse app.po
http://localhost:3000/api/data/v8.0/something
app.post('/api/data/v8.0/something', function (req, res) {
res.send({data:'1234A'});
});
http://localhost:3000/api/data/v8.0/something(ABC)/somethingelse
app.post('/api/data/v8.0/something(ABC)/somethingelse', function (req, res) {
res.send({data:'1234A'});
});
失败路线:
http://localhost:3000/api/data/v8.0/something
app.post('/api/data/v8.0/something', function (req, res) {
res.send({data:'1234A'});
});
http://localhost:3000/api/data/v8.0/something(ABC)/somethingelse
app.post('/api/data/v8.0/something(ABC)/somethingelse', function (req, res) {
res.send({data:'1234A'});
});
route Path中的括号有特殊含义,但看起来您可以像这样对其进行转义:
app.post('/api/data/v8.0/something[(]ABC[)]/somethingelse', function (req, res) {
res.send({data:'1234A'});
});
尝试将
(
替换为%28
和)
替换为%29
嗨,我无法在发送端更改它,但我已尝试将路由更改为encoded,但它不起作用。谢谢!这就是答案!