我刚刚使用 Node 和以下脚本将我的第一个 AngularJS
应用程序部署到 Heroku。
现在该网站的URL是http://project.herokuapp.com/ 。但是,我希望它是 http://project.herokuapp.com/beta 。我怎样才能做到这一点?
var gzippo = require('gzippo');
var express = require('express');
var app = express();
app.use(gzippo.staticGzip("" + __dirname + ""));
app.listen(process.env.PORT || 5000);
最佳答案
加急 (4x) Router()
你可以做到的。例如:
// declare your router
var router = express.Router();
// define your routes
router.get('/', function(req, res) {
// do your stuff
});
// define other routes and so on...
// ...and make shure all your routes will be prefixed with /beta
app.use('/beta', router);
现在,http://project.herokuapp.com/beta
是主路径,其他路由将始终以/beta
为前缀
关于javascript - 修改 Node 服务器的URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26301991/