About the separation of the front and rear ends of eggjs and vue.

how to deploy the eggjs used in the vue backend api for the front end? which folder of the packaged vue project is placed in egg? how to configure it? please give us some advice

Dec.27,2021

you said separation

  1. eggjs in a separate folder is generally named server
  2. the static pages generated by packaging can be named view
  3. in a separate folder.

static files use nginx reverse proxy to start egg.js service

I hope I can help you. Recommend my Y-leg tutorial http://yitianyibu.com/p/58df3. Welcome to my official account: Front-end Guide

if your project is called test , the domain name is www.test.com
create a test directory, and put the nginx,vue files in it. eggjs put a new server or backend directory in test .


is placed in 'app/public/** to place static resources, optional, see the built-in plug-in egg-static.'


router.get("*", noCache(), controller.Home.Index);
< hr >
/**
 * Home Service
 */
public async Index() {
  const url = "http://cdn.server.host/mysite/index.html";
  const result = await this.ctx.curl(url);
  return result.data;
  // or
  const tpl = path.join(this.config.static.dir, "index.html");
  return await fs.readFile(tpl, "utf-8");
}
https://github.com/eggjs/egg/.

what is there to struggle with? you have said that the front and rear ends are separated and can be divided into two completely independent projects. Eggjs provides api while providing a url entry. This url entry file is when you deploy index.html, after the construction of your vue project. Nginx points to the vue project and finalizes the work

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be56c0-31794.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be56c0-31794.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?