如果我在package.json中将代理设置为“ http://localhost:8080/api”,并将“ api”粘贴在路线的前面,则一切正常。如果我不关闭api,则无济于事-我的状态为404。我看过的教程根本不包含“ / api”。我宁愿不要在所有路线上都贴上“ api”。
状态为200-
package.json-
"proxy": "http://localhost:8080/api"
服务器index.js-
`app.get('/api/ping', function(req, res) {
res.send('(◍•ᴗ•◍)❤ pong');
});`
这将显示状态404-
package.json-
"proxy": "http://localhost:8080"
服务器index.js-
`app.get('/ping', function(req, res) {
res.send('(◍•ᴗ•◍)❤ pong');
});`