diff --git a/packages/next/src/withPayload.js b/packages/next/src/withPayload.js index a52c131de0e..fff14cabe1f 100644 --- a/packages/next/src/withPayload.js +++ b/packages/next/src/withPayload.js @@ -146,9 +146,6 @@ export const withPayload = (nextConfig = {}) => { if (nextConfig.basePath) { toReturn.env.NEXT_BASE_PATH = nextConfig.basePath } - if (nextConfig.assetPrefix) { - toReturn.env.NEXT_ASSET_PREFIX = nextConfig.assetPrefix - } return toReturn } diff --git a/packages/payload/src/index.ts b/packages/payload/src/index.ts index 0c9b38b9f07..6df1409955c 100644 --- a/packages/payload/src/index.ts +++ b/packages/payload/src/index.ts @@ -883,7 +883,9 @@ export const getPayload = async ( const port = process.env.PORT || '3000' const path = '/_next/webpack-hmr' - const prefix = process.env.NEXT_BASE_PATH ?? process.env.NEXT_ASSET_PREFIX ?? '' + // The __NEXT_ASSET_PREFIX env variable is set for both assetPrefix and basePath (tested in Next.js 15.1.6) + const prefix = process.env.__NEXT_ASSET_PREFIX ?? '' + cached.ws = new WebSocket( process.env.PAYLOAD_HMR_URL_OVERRIDE ?? `ws://localhost:${port}${prefix}${path}`, )