Skip to content

Commit f4d3080

Browse files
Fix redirection with nginx and http2
1 parent 2f9b942 commit f4d3080

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,8 @@ class Component {
15171517
const backendResponse = new BackendResponse(response);
15181518
thisPromiseResolve(backendResponse);
15191519
const html = await backendResponse.getBody();
1520-
if (backendResponse.response.headers.get('Content-Type') !== 'application/vnd.live-component+html') {
1520+
const headers = backendResponse.response.headers;
1521+
if (headers.get('Content-Type') !== 'application/vnd.live-component+html' && !headers.get('X-Live-Redirect')) {
15211522
this.renderError(html);
15221523
return response;
15231524
}

src/LiveComponent/assets/src/Component/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ export default class Component {
302302
thisPromiseResolve(backendResponse);
303303
const html = await backendResponse.getBody();
304304
// if the response does not contain a component, render as an error
305-
if (backendResponse.response.headers.get('Content-Type') !== 'application/vnd.live-component+html') {
305+
const headers = backendResponse.response.headers;
306+
if (headers.get('Content-Type') !== 'application/vnd.live-component+html' && !headers.get('X-Live-Redirect')) {
306307
this.renderError(html);
307308

308309
return response;

src/LiveComponent/src/EventListener/LiveComponentSubscriber.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
class LiveComponentSubscriber implements EventSubscriberInterface, ServiceSubscriberInterface
4848
{
4949
private const HTML_CONTENT_TYPE = 'application/vnd.live-component+html';
50+
private const REDIRECT_HEADER = 'X-Live-Redirect';
5051

5152
public function __construct(private ContainerInterface $container)
5253
{
@@ -282,7 +283,7 @@ public function onKernelResponse(ResponseEvent $event): void
282283

283284
$event->setResponse(new Response(null, 204, [
284285
'Location' => $response->headers->get('Location'),
285-
'Content-Type' => self::HTML_CONTENT_TYPE,
286+
self::REDIRECT_HEADER => 1,
286287
]));
287288
}
288289

0 commit comments

Comments
 (0)