App route matching all urls


I am working on an app with VueJS which uses its own router. Now I would like to pass on the full url after the appname to the Vue router: “/nextcloud/index.php/apps/appname/…/…/…”.

I could not find any documentation on the particular structure of routing nextcloud is using, unfortunately. Does it exist? In the examples on the app development pages there is given a way to allow any subdirectory to match with a route:


return [
    'routes' => [
	   ['name' => 'page#index', 'url' => '/{subpage}', 'verb' => 'GET'],

The problem with this route however is that it will only match one level, so e.g. /sub1 works, but /sub1/sub2 will fail. Is there any way to match all possible subroutes as well?

Thanks in advance!

I think you need to read this:

The secret sauce is adding a requirements parameter such as:

'requirements' => array('path' => '.+')

Thanks! Finally got it working now. I had to change it to the following though:

return [
	'routes' => [
		    'name' => 'page#index',
		    'url' => '/{path}',
		    'verb' => 'GET',
		    'requirements' => ['path' => '.+'] 

It did not work with the array( ) as suggested, but I had to use ‘[’ and ‘]’.

Also a note for others who use this with VueJS 2.x router: the Vuerouter should have the options

mode: 'history', hashbang: false,

set for it to work.