Answer the question
In order to leave comments, you need to log in
Development: server - node.js, client - vue.js. How to combine?
Good afternoon!
Problem:
there is a server on node.js + express that sends a URL (like: '/api/users/all') from a json database with data that needs to be taken to vue (project created via vue-cli) via fetch() or axios().
Development is carried out on the local computer.
The server is running on port 3000, the client is on 8080.
If I access the server from the client using the server:3000/api/users/all link , then a CORS error occurs (which can be solved by allowing cross server requests).
If I write the internal URL '/api/users/all' in the client, which I access in fetch(), I throw the result of the request into data() on vue in the client and then I form the bundle via "npm run build", after which I throw the bundle into the public folder of the server on Node.js - then everything works fine, but there is an inconvenience in terms of development, since for any change in the client, you need to form a deploy bundle and copy it manually to the public folder on the server.
What approaches do you use in this case and is it correct at all?
Answer the question
In order to leave comments, you need to log in
If I access the server from the client using the link server:3000/api/users/all, then a CORS error occurs (which can be solved by allowing cross server requests).
npm i cors
If I write the internal URL '/api/users/all' in the client, which I access in fetch(), I throw the result of the request into data() on vue in the client and then I form the bundle via "npm run build", after which I throw the bundle into the public folder of the server on Node.js - then everything works fine, but there is an inconvenience in terms of development, since for any change in the client, you need to form a deploy bundle and copy it manually to the public folder on the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question