Boa tarde,
Fiz as modificações na aplicação e instalei e configurei o webpack dev server porem quando acesso a pagina http://localhost:8080/ me é apresentado os seguintes erros no console:
POST http://localhost:3000/negociacoes net::ERR_CONNECTION_REFUSED (anonymous) @ bundle.js:9775 webpack_require @ bundle.js:20 (anonymous) @ bundle.js:707 webpack_require @ bundle.js:20 (anonymous) @ bundle.js:63 (anonymous) @ bundle.js:66
localhost/:1 Uncaught (in promise) TypeError: Failed to fetch Promise.then (async) (anonymous) @ bundle.js:9775 webpack_require @ bundle.js:20 (anonymous) @ bundle.js:707 webpack_require @ bundle.js:20 (anonymous) @ bundle.js:63 (anonymous) @ bundle.js:66
As minhas configurações estão da seguinte forma:
app.js
fetch('http://localhost:3000/negociacoes', config)
.then(() => console.log('Dado enviado com sucesso'));
webpack.config.js
module.exports = {
entry: './app-src/app.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname,'dist'),
publicPath: 'dist'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins
}
express.js
var express = require('express')
,app = express()
,routes = require('../app/routes')
,path = require('path')
,bodyParser = require('body-parser');
// app.set('clientPath', path.join(__dirname, '../..', 'client'));
// console.log(app.get('clientPath'));
// app.use(express.static(app.get('clientPath')));
app.use(bodyParser.json());
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});