Is it possible to set a base URL for NodeJS app?

前端 未结 7 519
有刺的猬
有刺的猬 2020-11-29 19:51

I want to be able to host multiple NodeJS apps under the same domain, without using sub-domains (like google.com/reader instead of images.google.com). The problem is that I\

相关标签:
7条回答
  • 2020-11-29 20:24

    I was able to achieve this using a combination of express-namespace for the routes and a fix from the below google group discussion for the static assets. This snippet will treat a request to /foo/javascripts/jquery.js like a request to /javascripts/jquery.js:

    app.use('/foo', express.static(__dirname + '/public'));
    

    Source: https://groups.google.com/forum/#!msg/express-js/xlP6_DX6he0/6OTY4hwfV-0J

    0 讨论(0)
提交回复
热议问题