There is a bug/issue with
javascript <PayloadLivePreview
refresh={() => router.refresh()}
serverURL={process.env.NEXT_PUBLIC_SERVER_URL!}
/> and
PayloadRedirectscomponent, everything is ok in dev mode, but when it's on production...

Can you check your redirects implementation is okay? Last time this was raised the redirects setup wasn't proper. This is the website template correct?
Like the actual redirects collection had wrong data
Yes, website template
Fresh install?
almost fresh
I just added few things
Seeded right? And what Payload version?
What does your redirects collection look like
latest, this bug is from 1m ago, The only that helped me was to create a root layout before (the frontend) and (payload), but that caused some other bugs
the reason why I create a "new" fresh project is just to see what is wrong... It's really annoying...
This has been brought up a few times before and no ones been able to have a consistent reproduction so far
1st time when I realized that I had a bug
its this thing again
In a video call Ivan showed that wrapping the (frontend) + (backend) in a root layout actually fixes it with some obvious side effects of invalid html structure
I did my best to reproduce the error...
I had this issue when I added versioning and live pre-views
aftermy pages were created. My fix was simply deleting my exisiting pages and remaking them.
I finally fix it!!!!!
@654031862146007055@858693520012476436
here is the solution
'use client';
import { RefreshRouteOnSave as PayloadLivePreview } from '@payloadcms/live-preview-react';
import { useRouter } from 'next/navigation';
import React, { useState } from 'react';
export const LivePreviewListener: React.FC = () => {
const router = useRouter();
const [hasError, setHasError] = useState(false);
// Error handling function
const handleRefresh = async () => {
try {
// Perform a fetch request to check if the current route exists
const response = await fetch(window.location.href, {
method: 'HEAD',
cache: 'no-store',
});
console.log(
'Response status:',
response.status,
'Response status text:',
response.statusText,
);
// If the response is not OK (status code is not 2xx), set error state
if (!response.ok) {
setHasError(true);
} else {
// Otherwise, refresh the route
router.refresh();
}
} catch (error) {
// Catch any network errors and set error state
console.error('Error checking route:', error);
setHasError(true);
}
};
// Return null if there's an error
if (hasError) {
return null;
}
return (
<PayloadLivePreview
refresh={handleRefresh}
serverURL={process.env.NEXT_PUBLIC_SERVER_URL!}
/>
);
};

Hey
@402788885366833183what version of live-preview-react are you requiring in package.json?
I'm getting
Module '"@payloadcms/live-preview-react"' has no exported member 'RefreshRouteOnSave'.ts(2305)Latest? You?
THANKYOU
@402788885366833183🙏
Star
Discord
online
Get dedicated engineering support directly from the Payload team.