代码拉取完成,页面将自动刷新
const express = require('express')
const path = require('path')
/* eslint-disable new-cap */
const app = new express()
/* eslint-enable new-cap */
const config = require('./config')
const port = process.env.PORT || 3000
app.use(express.static('client'))
/**
* Note: Generally we don't need an application server for serving
* static files; instead we can use a web server such as nginx for static resources.
*/
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
next()
})
app.get('/static/*', (req, res) => {
res.sendFile(path.join(config.build.assetsRoot, req.path))
})
app.get('*', (req, res) => {
res.sendFile(config.build.index)
})
app.listen(port, () => {
console.log(`local server listening on port ${port}`)
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。