Reputation: 177
I cloned an angular2-webpack-starter project and it works well; now I want to add a separate NodeJS server to this project(I need to mock some data with NodeJS for back-end), but don't know how and where to start, can someone help?
Upvotes: 2
Views: 184
Reputation: 177
This issue was resolved, just need to config proxy of devServer in config/webpack.dev.js:
module.exports = {
entry:{...},
...
devServer: {
host: 'localhost',
port: 8086, //frontend port
historyApiFallback: true,
noInfo: true,
watchOptions: {
aggregateTimeout: 300,
poll: 100
},
outputPath: '/',
proxy: {
'/api/*': { //backend url prefix, some thing like '/api/users/:userId'
target: 'http://localhost:3000', // backend host and port
secure: false
}
}
}
};
Upvotes: 1