laravel / nova-issues

554 stars 34 forks source link

Conflicting with my SPA #2070

Closed ghost closed 5 years ago

ghost commented 5 years ago

Description

Nova always trigger middlewareGroup['web'], but it is conflict with my spa based on jwt - without sessions My middlewareGroup is:

        'web' => [
            // \App\Http\Middleware\EncryptCookies::class,
            // \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            // \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            // \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            // \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

So, Nova require errors shared from session

Where is triggering: NovaApplicationServiceProvider.php:40 NovaApplicationServiceProvider.php:41

    protected function routes()
    {
        Nova::routes()
                ->withAuthenticationRoutes()
                ->withPasswordResetRoutes();
    }

Hardcoded 'web' is in: PendingRouteRegistration.php:54

public function withAuthenticationRoutes($middleware = ['web'])

PendingRouteRegistration.php:24

public function withAuthenticationRoutes($middleware = ['web'])

I suggest to make config entry and move $middleware=['web'] to $middleware=[] And call as

    protected function routes()
    {
        Nova::routes()
                ->withAuthenticationRoutes(config('nova.middlewareGroup'))
                ->withPasswordResetRoutes(config('nova.middlewareGroup'));
    }

So, this solution prevent to conflicting with another SPA or PWA apps.

jbrooksuk commented 5 years ago

The vast majority of websites are not SPAs and so the defaults reflect that. You're free to override the middleware, as you've noticed :)

ghost commented 5 years ago

i know about middleware free overriding, i asking for remove hardcoded middleware call from nova. because of it many devs experiencing troubles. i suggest an solution for it, simple and fastest. where we can override middleware by createing one only for nova, then call them via configuration. whats wrong ?