Skip to content

Commit ec658a4

Browse files
authored
fix(live-preview): remove payload import (#15160)
Fixes #15024. The `@payloadcms/live-preview` package was importing from `payload/shared`, which is not a dependency of this module. This causes installations that are not running a payload as a peer dependency to crash, e.g. Svelte frontends, etc. The use of `formatAdminURL` doesn't really make sense here anyway as it relies on Next.js' base path. The SDK is designed to be front-end agnostic. If needed, the user should just include it in the `serverURL` they provide.
1 parent 9d54267 commit ec658a4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/live-preview/src/mergeData.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { formatAdminURL } from 'payload/shared'
2-
31
import type { CollectionPopulationRequestHandler } from './types.js'
42

5-
const defaultRequestHandler: CollectionPopulationRequestHandler = ({ apiPath, data, endpoint }) => {
6-
const url = formatAdminURL({
7-
apiRoute: apiPath,
8-
path: `/${endpoint}`,
9-
})
3+
const defaultRequestHandler: CollectionPopulationRequestHandler = ({
4+
apiPath,
5+
data,
6+
endpoint,
7+
serverURL,
8+
}) => {
9+
const url = `${serverURL}${apiPath}/${endpoint}`
1010

1111
return fetch(url, {
1212
body: JSON.stringify(data),

0 commit comments

Comments
 (0)