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
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
you said separation
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
.Previous: Switching between source tags and url, videos in the video tag has not been replaced.
Next: On the value of react