Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Move index route to new route group #247

Closed
Firtzberg opened this issue Apr 9, 2020 · 2 comments · Fixed by #249
Closed

Move index route to new route group #247

Firtzberg opened this issue Apr 9, 2020 · 2 comments · Fixed by #249

Comments

@Firtzberg
Copy link
Contributor

The index route in the routes/web.php is misplaced and web middleware group not appropriate for web requests. The web routes and middleware are meant for session related requests as you can read in the app/Providers/RouteServiceProvider.php.

This in general is no big deal until you start integrating 3rd party packages like laravel-roles which use the 'web' middleware internally for their builtin admin panel.

I used that package in my project and realized the proper way to do this is to restore the 'web' middleware group and create a new one for my SPA index only. I added a new mapping to the RouteServiceProvider as below and moved the spa index endpoint to a new routes file.

    /**
     * Define the "spa" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapSpaRoutes()
    {
        Route::middleware('spa')
             ->namespace($this->namespace)
             ->group(base_path('routes/spa.php'));
    }

This allows me to have the API routes, SPA application and MVC based administration panel working side-by-side.

@Firtzberg Firtzberg changed the title Moe index route to new route group Move index route to new route group Apr 9, 2020
@Firtzberg
Copy link
Contributor Author

Firtzberg commented Apr 9, 2020

@cretueusebiu Let me know if you're interested in a PR.
Possibly related

@cretueusebiu
Copy link
Owner

If you could create a PR that would be great!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants