如何使用Node.js+;Express.js?
我有一个gzipped angular应用程序,我想使用express为其提供服务。这就是我到目前为止所做的如何使用Node.js+;Express.js?,node.js,angular,express,gzip,Node.js,Angular,Express,Gzip,我有一个gzipped angular应用程序,我想使用express为其提供服务。这就是我到目前为止所做的 已将gzip应用程序复制到我的服务器目录(管理目录) 在express中,创建了获取“/”路由以检索index.html 为所有其他应用程序的文件(js、css)创建了另一个路由 由于某种原因,当我向“/”发送get请求时,浏览器会下载gzip html而不是呈现它(而且它是一个损坏的文件,无法打开) 我宣布的第二条路线也不起作用 app.get('/', (req: express.
app.get('/', (req: express.Request, res: express.Response, next: express.NextFunction) =>{
return res.sendFile('index.html.gz', {root: 'admin'})
})
app.use('/*', (req: express.Request, res: express.Response, next: express.NextFunction) =>{
res.set('Content-Encoding', 'gzip')
next()
}, express.static('admin'))