javascript 用于在节点#nodejs #javascript内设置react app的代码片段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 用于在节点#nodejs #javascript内设置react app的代码片段相关的知识,希望对你有一定的参考价值。

if (process.env.NODE_ENV === 'production') {
    //Express will serve up production assets
    //like our main.js file, or main.css file
    app.use(express.static('client/build'));

    //Express will serve up the index.html file
    //if it doesn't recognize the route
    //note 1: if it doesn't recognize the file being scanned above(static/client/build), then it will go through here to find the index.html file. This route is a catch-all scenario just to load the client app in express server.
    const path = require('path');
    app.get('*', (req, res) => {
        res.sendfile(path.resolve(__dirname, 'client', 'build', 'index.html'));
    });

}

以上是关于javascript 用于在节点#nodejs #javascript内设置react app的代码片段的主要内容,如果未能解决你的问题,请参考以下文章

用于在节点 js javascript 文件中发送用户消息的 gmail API

javascript [节点API-路径] #NodeJs

javascript [freshdesk节点核心] freshdesk nodejs纯#customer

门罗币 nodejs 文档

sh [bash:vagrant中的调试节点] #bash scipts用于#development和#debug #nodejs在#vagrant机器中

javascript 用于下载(http)URI的NodeJS模块。