@@ -99,13 +99,20 @@ public function onKernelResponse(ResponseEvent $event): void
99
99
return ;
100
100
}
101
101
102
+ $ location =$ response ->headers ->get ('Location ' );
103
+
102
104
if ($ response ->headers ->has ('X-Debug-Token ' ) &&$ response ->isRedirect () &&$ this ->interceptRedirects &&'html ' ===$ request ->getRequestFormat ()) {
103
105
if ($ request ->hasSession () && ($ session =$ request ->getSession ())->isStarted () &&$ session ->getFlashBag ()instanceof AutoExpireFlashBag) {
104
106
// keep current flashes for one more request if using AutoExpireFlashBag
105
107
$ session ->getFlashBag ()->setAll ($ session ->getFlashBag ()->peekAll ());
106
108
}
107
109
108
- $ response ->setContent ($ this ->twig ->render ('@WebProfiler/Profiler/toolbar_redirect.html.twig ' , ['location ' =>$ response ->headers ->get ('Location ' ),'host ' =>$ request ->getSchemeAndHttpHost ()]));
110
+ // if there is no location, then we can't show it to the user
111
+ if (!$ location ) {
112
+ return ;
113
+ }
114
+
115
+ $ response ->setContent ($ this ->twig ->render ('@WebProfiler/Profiler/toolbar_redirect.html.twig ' , ['location ' =>$ location ,'host ' =>$ request ->getSchemeAndHttpHost ()]));
109
116
$ response ->setStatusCode (200 );
110
117
$ response ->headers ->remove ('Location ' );
111
118
}