node.js - Hosting Emberjs Application on Koajs with koa-static -


I am hosting an ambergas application on com. According to the code given below:

  var app = koa (); Var app 1 = koa (); App1.use (static (__DERNAM + "/ AP1")); App.use (mount ('/ AppViewer', APP1)); App.listen (3000); I can not see my page when calling  localhost: 3000 / AppViewer  and the error says that .js and .css files can not be found, but when calling  localhost: 3000 / AppViewer / index.html  All things work correctly so my question is how to view my page when calling  localhost: 3000 / AppViewer . 

First of all, it looks weird, because index.html on the code-static route The default is to make sure that App1 is not anywhere else / routing.

Then, you can get rid of index.html using something like this in the URL:

  var rewrite = require (to -re right'); App1.use (rewrite ('/ *', '/index.html'));   

UPDATE

Tested with the following code:

  var koa = require ('koa '); Var app = cua (); Var app 1 = koa (); Var mount = is required ('koa-mount'); Var service = requirement ('coa-stationary'); Var rewrite = requirement ('co-rewrite'); Var route = requirement ('co-root'); App1.use (service (__dirname + "/ app1")); App1.use (rewrite ('/ *', '/index.html')); App.use (mount ('/ av', app1)); App.use (route.get ('/', function * (Next) {this.body = 'I' to the main app! ';})); App.listen (3000);  

Comments