Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/LiveComponent/assets/dist/live_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,8 @@ class Component {
const backendResponse = new BackendResponse(response);
thisPromiseResolve(backendResponse);
const html = await backendResponse.getBody();
if (backendResponse.response.headers.get('Content-Type') !== 'application/vnd.live-component+html') {
const headers = backendResponse.response.headers;
if (headers.get('Content-Type') !== 'application/vnd.live-component+html' && !headers.get('X-Live-Redirect')) {
this.renderError(html);
return response;
}
Expand Down
3 changes: 2 additions & 1 deletion src/LiveComponent/assets/src/Component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ export default class Component {
thisPromiseResolve(backendResponse);
const html = await backendResponse.getBody();
// if the response does not contain a component, render as an error
if (backendResponse.response.headers.get('Content-Type') !== 'application/vnd.live-component+html') {
const headers = backendResponse.response.headers;
if (headers.get('Content-Type') !== 'application/vnd.live-component+html' && !headers.get('X-Live-Redirect')) {
this.renderError(html);

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
class LiveComponentSubscriber implements EventSubscriberInterface, ServiceSubscriberInterface
{
private const HTML_CONTENT_TYPE = 'application/vnd.live-component+html';
private const REDIRECT_HEADER = 'X-Live-Redirect';

public function __construct(private ContainerInterface $container)
{
Expand Down Expand Up @@ -282,7 +283,7 @@ public function onKernelResponse(ResponseEvent $event): void

$event->setResponse(new Response(null, 204, [
'Location' => $response->headers->get('Location'),
'Content-Type' => self::HTML_CONTENT_TYPE,
self::REDIRECT_HEADER => 1,
]));
}

Expand Down