我正在尝试使用 Node.js 为 Last.fm 的网络服务设置代理。问题是对 ws.audioscrobbler.com 的每个请求都被重写为 www.last.fm。因此,例如发送一个to 。$ curl http://localhost:8000/_api/test123
301 Moved Permanently
http://www.last.fm/test123
var express = require('express'),
httpProxy = require('http-proxy');
// proxy server
var lastfmProxy = httpProxy.createServer(80, 'ws.audioscrobbler.com');
// target server
var app = express.createServer();
app.configure(function() {
app.use('/_api', lastfmProxy);
});
app.listen(8000);
同时返回一个正则. 我不确定我在这里缺少什么,或者我是否完全错误地处理了这个问题。$ curl http://ws.audioscrobbler.com/test123
404 Not Found