你需要把路徑正在渲染你的應用程序的HTML文件來
app.get("/",(res,res) => {
res.sendFile('put the path of the html file you are rendering your app into here');
}
這裏是可與反應的快遞server.js的例子
var express = require('express');
var bodyParser = require('body-parser');
var logger = require('morgan');
var app = express();
var PORT = process.env.PORT || 3000;
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.text());
app.use(bodyParser.json({type: 'application/vnd.api+json'}));
app.use(express.static('./public'));
app.get('/', function(req,res){
res.sendFile('./public/index.html');
});
app.listen(PORT, function(){
console.log("Listening on port: " + PORT);
});
你爲什麼在你的快速路線中使用*!你的其他API的名稱是什麼? –
你想做什麼?你想用express來爲js/html服務前端靜態文件嗎? –