我希望我理解正確你的問題,你實際上可以使代理請求和管道這是針對你的應用程序的響應。
var http = require("http");
var express = require("express");
var app = express();
var options = {
host: "stackoverflow.com",
port: 80,
path: "/",
method: "GET",
headers: {}
};
app.get("/stackoverflow*", function (request, response) {
"use strict";
var proxyRequest;
options.headers.cookie = request.headers.cookie;
options.headers["user-agent"] = request.headers["user-agent"];
// TODO set other headers if needed
options.path = "/" + request.path.split("/").slice(2).join("/");
options.method = request.method;
proxyRequest = http.request(options, function (proxyResponse) {
proxyResponse.pipe(response);
});
request.pipe(proxyRequest);
}).listen(8080);
現在你可以瀏覽到http://localhost:8080/stackoverflow/questions/14880557/how-to-connect-appjs-to-nodejs-server-and-show-its-content/14890268#14890268
和您的應用程序將顯示來自stackoverflow.com
請求的路徑。
您是否問過如何使用您的'節點從您的網站下載遠程內容。js'應用程序並提供內容與它? – fardjad 2013-02-14 17:28:52
不,不下載。就好像瀏覽器會是app.js.它只顯示來自我的節點服務器的內容。 – RedDot 2013-02-14 19:45:05