mariovalney / laravel-keycloak-web-guard

Simple Keycloak Guard to Laravel Web Routes - https://packagist.org/packages/vizir/laravel-keycloak-web-guard
146 stars 80 forks source link

Fix login redirect for Inertia apps. #107

Closed codegourmet closed 6 months ago

codegourmet commented 1 year ago

Inertia calls are executed via AJAX, so when one of those runs into an expired session, a CORS error will be triggered (the login redirect will result in a different URL than indicated in the preflight request).

This commit catches Inertia calls and does a hard Inertia redirect. This will not impact other AJAX calls. Also, this only needs to be handled in the keycloak.login route, since that can be triggered any time via the KeycloakAuthenticated middleware.

mariovalney commented 6 months ago

Hi! Thanks for your PR.

But it's very specific need so: