Enonic version: 6.11.1
I’m trying to use the router lib but can’t seem to get it to work.
- If I try adding it to main.js. as the doc say nothing happens not even in the filter so the request isnt intercepted.
- If i add the same code in an controller. The filter is triggered but not any routes.
Is there an special app path that must be used to trigger the router in main.js ?
Is there a demo APP that I can take a look at using the router ?
The main.js controller can be accessed in the URL
/app/<app-id> , e.g. /app/com.enonic.myapp . We updated the documentation recently. Let us know if anything can be improved.
You can also configure a vhost for the app path to access it in a different URL.
Currently the router does not work from other controllers (service, page, controller mapping). We are working on fixing that, but it will probably require some small changes in XP (not just the router lib), so it would be fixed for next XP release.
There is no demo app using the router yet. But it’s a good idea.
I’m using vhost for another app on the same server. So I needed to add an mapping in vhost the get the app to work.
Example if vhost is enabled and get an APP to accept requests on /app as described here: http://xp.readthedocs.io/en/6.12/developer/app-controller/index.html and getting the router lib to work as described here: https://enonic-docs.s3.amazonaws.com/com.enonic.lib/lib-router/index.html
mapping.app.host = localhost
mapping.app.source = /app
mapping.app.target = /app
mapping.app.userStore = system
If I understood correctly your problem was vhost.
For other people trying out apps in 6.11, I just leave this here: While trying out applications, I noticed that calls to the root of the app and finishing with a slash do not trigger the main.js
http://localhost:8080/app/com.enonic.app.myapp -> Application main.js called
http://localhost:8080/app/com.enonic.app.myapp/ -> Application main.js not called
It has been fixed in 6.12.1