糖尿病网pc端官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
1.2 KiB

const Koa = require('koa');
const { Nuxt, Builder } = require('nuxt');
const dotenv = require('dotenv');
console.log('==========env:', process.env.NODE_ENV);
if (process.env.NODE_ENV !== 'production') {
// dotenv.config('.env');
} else {
console.log('===+++++++++++');
// dotenv.config('./.env.production');
}
dotenv.config('.env');
console.log(
'===+++++++++++',
process.env.BROWSER_BASE_URL,
process.env.PROXY_URL
);
// console.log("==========env2:", process.env);
async function start() {
const app = new Koa();
// Import and Set Nuxt.js options
const config = require('./nuxt.config.js');
config.dev = process.env.NODE_ENV !== 'production';
const { host, port } = config.server;
// Instantiate nuxt.js
const nuxt = new Nuxt(config);
// Build in development
if (config.dev) {
const builder = new Builder(nuxt);
await builder.build();
}
app.use((ctx) => {
ctx.status = 200;
ctx.respond = false; // Mark request as handled for Koa
ctx.req.ctx = ctx; // This might be useful later on, e.g. in nuxtServerInit or with nuxt-stash
nuxt.render(ctx.req, ctx.res);
});
app.listen(port, host);
console.log('Server listening on ' + host + ':' + port); // eslint-disable-line no-console
}
start();