我正在使用带有easyrtc的node.js,需要重写url或删除斜杠后的任何url
请找到我的server.js
var http = require("http");
var express = require("express");
var io = require("socket.io");
var easyrtc = require("easyrtc");
var httpApp = express();
httpApp.configure(function() {
httpApp.use(express.static(__dirname + "/static/"));
});
var webServer = http.createServer(httpApp).listen(9099);
var socketServer = io.listen(webServer, {"log level":5});
var rtc = easyrtc.listen(httpApp, socketServer);
我可以在哪里添加脚本来重写网址?
答案 0 :(得分:1)
httpApp.configure(function() {
httpApp.use(function(req, res, next){
if(req.url === '/myOldRoute'){
req.url = '/myNewRoute'
}
next();
});
httpApp.use(express.static(__dirname + "/static/"));
});