Angular2 Webpack and Express
Angular2 Webpack and Express
我已经安装了Angular 2 Webpack,其中包括一个示例应用程序并演示了路由。我想研究的是使用Angular2作为前端路由,但使用ExpressJS作为RESTful API后端,但在同一服务器上,即
http://localhost:3000/#/将服务于Angular的前端http://localhost:3000/api将在Express中提供后端API
如果我创建一个api/index.html,我可以看到这显示了api的主页,但我还没有得到一个线索如何创建'app.js'为express获得快速路由工作。
我很感激我可以通过运行两个实例轻松地做到这一点,但我试图保持它全部是独立的。
对
我找不到在同一端口上这样做的方法,所以我把它放在config/webpack.common.js中。(我原以为我需要为API启动一个单独的'npm'进程,但显然不是!)
var express = require('express');
var app2 = express();
app2.get('/', function (req, res) {
res.send('API');
});
app2.listen(3001, function () {
});
相关文章:
- Express Session and Cookie
- Use React and Express
- jade, express, and mysql results
- use express.bodyParser() and passport.js
- Express.js res.render() and res.redirect()
- Cluster with Express.js and Kue.js
- Node.js and Express - 将JSON对象从SoundCloud API发送到前端使其成为字符串
- NodeJS/Express app.use sequence and usage
- NodeJS and express, ENOENT on view file
- Node JS, Socket.IO, Express and Http connection
- 'Write after end' error with Express, csvtojson and
- Express.js and Angular.js html5mode (Avoiding # in url)
- FailureFlash with Passportjs and Express
- Express, http-proxy-middleware and net::ERR_CONNECTION_REFUS
- Angular2 Webpack and Express
- Node.js, express, jade, highcharts and 2D array
- Nodejs, php and express
- CORS Error: Angular.JS, Node.JS and Express
- NodeJS, express and mongoDB - mapping logic
- Express and Cheerio/JSDOM