Multi-language routes in express.js?

后端 未结 5 1555
终归单人心
终归单人心 2020-12-29 07:30

I\'m wondering if there is a best practise example on how to implement multi-lanuage routes in express.js. i want to use the accept-language header to get the b

5条回答
  •  感动是毒
    2020-12-29 07:46

    Not sure how you plan on organizing or sharing content but you can use regular expressions with express routes and then server up different templates. Something like this:

    app.get(/^\/(startseite|home)$/, function(req, res){
    
    });
    

    One thing that I did was to organize my content with subdomains and then use middleware to grab the content out of the database based splitting the url, but they all shared the same routes and templates.

提交回复
热议问题