0👍
Looks like axios is making the request on port 8080
.
You can specify the correct port number in the .get
method like so:
axios.get('/api/users', { port: 3000 }).then(...)
0👍
add in Server.js, you problem Cross-domain.
In place do not origin your url than accesses the vue.js
app.all('*', function (req, res, next) {
var origin = req.get('origin');
res.header('Access-Control-Allow-Origin', 'http://localhost:8080');
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-type, Accept, Authorization');
if (req.method === 'OPTIONS') {
return res.status(200).end();
}
next();
});
- [Vuejs]-Start client and server in one command using Vue-cli / Webpack
- [Vuejs]-How to create new component data based on existing in Vue.js
0👍
Finally worked it out. I needed to add the below code to the webpack.config file:
devServer: {
proxy: {
'/api/*' : {
target: 'http://localhost:3000'
}
}
}
- [Vuejs]-Why async function continues after await (in vuex)
- [Vuejs]-How to download .docx documents with Vue/Laravel
Source:stackexchange.com