Laravel-modules: Laravel Routes + VueJS, routes are being overwritten

Created on 4 Oct 2019  路  4Comments  路  Source: nWidart/laravel-modules

Hello,

Well, I have a problem with my routes, all requests related to the Modules folders doesn't work.

In my project-folder/routes/web.php I must use in that way because my front is in VueJs:

Route::get('/{any}', 'ApplicationController')->where('any', '.*');

Ok, I was using routes into the main api.php file, working fine, but when I put in Modules/ModuleName/Routes/api.php the route doesn't work:

`Route::group(['middleware' => 'auth:api'], function () {

Route::get(
    'opportunity/kanban',
    '\App\Modules\Opportunity\Http\Controllers\OpportunityController@kanbanList'
);

Route::get(
    'opportunity/channel-sale',
    '\App\Modules\Opportunity\Http\Controllers\OpportunityController@channelSaleList'
);

Route::get(
    'opportunity/flow-steps',
    '\App\Modules\Opportunity\Http\Controllers\OpportunityController@flowStepList'
);

});`

If I remove the route::get('any')... from main web.php it works,
I believe the routes are having some kind of conflict.

All 4 comments

The main Laravel routes are registered before the ones from your module(s). The way to fix this is to put your module's route service provider ABOVE Laravel's route service provider in your config/app.php file.

I do not know how auto-discovery will affect this - if you're using that in your modules.

Another fix may be to put this package's service provider (instead of having to do each module's route service provider) above the Laravel route service provider, but I am not sure what other unintended consequences that would bring.

Hmm, ok, I will try this at monday, thanks!

Thank you @Keilost. I forgot about Route::fallback.

Was this page helpful?
0 / 5 - 0 ratings