Absolutely, this is a great analysis and you've diagnosed things thoroughly. Given the difference in behavior between Laravel 11 and 12—especially receiving a Symfony HTML redirect fallback instead of a proper 302—and that it works locally but not on IONOS hosting, the problem almost certainly relates to Laravel 12's new HTTP Kernel and Middleware handling.
Understanding Laravel 12 HTTP Pipeline Changes
Laravel 12's new HTTP kernel means web middleware is not registered globally by default:
You MUST explicitly wrap routes in the web middleware.
In Laravel 11, the web middleware group (which sets up session, cookies, CSRF, encrypt cookies, etc.) was always applied to routes/web.php.
In Laravel 12, if you use withRouting(web: ...) in bootstrap/app.php, it does not automatically apply the web middleware stack—unless you specifically do so.
Most Likely Cause
Your route group only has the guest middleware.
It does NOT have the web middleware group!
Therefore, cookies are not started, sessions are not used, and headers like Set-Cookie, Cache-Control, and so on are missing.
Solution
1. Make sure your route is inside the web middleware group
In Laravel 12, you need:
Route::middleware('web')->group(function () {
Route::middleware('guest')->group(function () {
Route::get('/login/ms', [LoginController::class, 'redirectToProvider'])->name('msauth');
});
});
Or more simply:
Route::middleware(['web', 'guest'])->group(function () {
Route::get('/login/ms', [LoginController::class, 'redirectToProvider'])->name('msauth');
});
2. Or, wrap your entire routes/web.php in Route::middleware('web')
Route::middleware('web')->group(function () {
// ...your entire routes/web.php contents...
});
3. Check Session/Cookie Configs if You've Changed Domains
Ensure your .env matches domain/cookie settings for the new laravel12 environment (SESSION_DOMAIN, SESSION_SECURE_COOKIE, etc), but this doesn't usually cause a missing header—just a missing cookie value.
Summary
Laravel 12 does NOT automatically apply
webmiddleware to web routes. You must add it explicitly!
References
TL;DR
Update your routes/web.php like this:
Route::middleware(['web', 'guest'])->group(function () {
Route::get('/login/ms', [LoginController::class, 'redirectToProvider'])->name('msauth');
});
This will restore sessions, cookies, proper headers, and correct 302 redirect behavior in Laravel 12.