Any way to serve static html files from express without the extension?

前端 未结 4 2104
青春惊慌失措
青春惊慌失措 2020-12-03 07:45

I would like to serve an html file without specifying it\'s extension. Is there any way I can do this without defining a route? For instance instead of

 /he         


        
4条回答
  •  悲&欢浪女
    2020-12-03 07:57

    you can just use extension option in express.static method .

    app.use(express.static(path.join(__dirname, 'public'),{index:false,extensions:['html']}));
    

提交回复
热议问题