serving static files with restify (node.js)

后端 未结 3 1727
臣服心动
臣服心动 2021-02-02 10:35

I have the following code:

app.js

[...]

server.get(/\\/docs\\/public\\/?.*/, restify.serveStatic({
  directory: \'./public\'
}));

server.listen(1337, f         


        
3条回答
  •  孤独总比滥情好
    2021-02-02 11:11

    Based on @NdeeJim's answer, to anyone wondering how to serve ALL the static resources:

    server.get(/\/?.*/, restify.plugins.serveStatic({
                directory: __dirname,
                default: 'index.html',
                match: /^((?!app.js).)*$/   // we should deny access to the application source
         }));
    

提交回复
热议问题