Express backend & Vue frontend
Run docker and visit http://localhost:8080:
$ docker-compose up
Create project folder:
$ mkdir express-vue $ cd express-vue
Create Express backend app, install dependencies:
$ express back $ cd back $ npm install
- Change default port from
3000
to8000
inbin/www
. Enable CORS in Express using following middleware:
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(); });
Install
vue client
:$ npm install -g @vue/cli
Create Vue frontend app in project folder, install dependencies:
$ vue create front
- Fetch data from Express backend through "http://localhost:8000/<path>" inside .vue files.
- Create separate
Dockerfile
in back and front apps anddocker-compose.yml
in project folder.