Redirect all trailing slashes globally in express

后端 未结 7 1667
醉话见心
醉话见心 2020-11-28 23:40

I am using Node.js and Express and I have the following routing :

app.get(\'/\', function(req,res){
    locals.date = new Date().toLocaleDateString();

    r         


        
7条回答
  •  一生所求
    2020-11-29 00:22

    The connect-slashes middleware was designed specifically for this need: https://npmjs.org/package/connect-slashes

    Install it with:

    $ npm install connect-slashes

    Read the full documentation: https://github.com/avinoamr/connect-slashes

提交回复
热议问题