我開始MEA2N應用程序,並構建了一個運行在端口3000上的小型快遞服務器。 角度應用程序運行在端口4200.如果我打開本地主機3000,正在加載...'如果應用程序無法運行。而如果我打開本地主機4000我得到'應用程序工作'。有人知道這可能會發生嗎?角度2文件直接工作,但不通過nodejs快遞文件
server.js是很標準:
// Get dependencies
const express = require('express');
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');
// Get our API routes
const api = require('./server/routes/api');
const app = express();
// Parsers for POST data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Point static path to dist
app.use(express.static(path.join(__dirname, 'dist')));
// Set our api routes
app.use('/api', api);
// Catch all other routes and return the index file
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, './src/index.html'));
});
/**
* Get port from environment and store in Express.
*/
const port = process.env.PORT || '3000';
app.set('port', port);
/**
* Create HTTP server.
*/
const server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port,() => console.log(`API running on localhost:${port}`));
server.js在根文件夾中運行。 角的應用程序是根/ SRC/indxex.html和根/ SRC /應用/
請包括您的文件夾結構和您的app.js – echonax