0

I have an API coded in Nodejs and an AngularJS app statically served by the same server.

I need to host another AngularJS app which should be served by the same server.

How can I do that? Can Restify or Express serve 2 static apps?

I used

server.get(/\/shared\/?.*/, restify.serveStatic({
  directory: __dirname + '/shared/.build',
  default: 'index.html'
}));

doesn't work if I write

http://127.0.0.1:3000/shared
Burak
  • 5,706
  • 20
  • 70
  • 110
  • It depends on how exactly you want to serve them. It would be relatively simple to serve the two apps from the same domain under two separate folders. – Kevin B Feb 10 '16 at 21:58

1 Answers1

1

This should work just fine:

app.use('/app1', express.static(path.join(__dirname, '/app1/.build')))
app.use('/app2', express.static(path.join(__dirname, '/app2/.build')))
Alex Lapa
  • 1,149
  • 11
  • 21