Skip to content

Commit

Permalink
Fix HMR with full assetPrefix URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
kane-c committed May 8, 2024
1 parent 0edf4f9 commit 9d13afe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/next/src/server/lib/router-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,15 @@ export async function initialize(opts: {
if (opts.dev && developmentBundler && req.url) {
const { basePath, assetPrefix } = config

// only prefix the URL with the asset prefix if it lacks a protocol
const prefix =
assetPrefix.startsWith('http://') ||
assetPrefix.startsWith('https://')
? ''
: assetPrefix || basePath

const isHMRRequest = req.url.startsWith(
ensureLeadingSlash(`${assetPrefix || basePath}/_next/webpack-hmr`)
ensureLeadingSlash(`${prefix}/_next/webpack-hmr`)
)

// only handle HMR requests if the basePath in the request
Expand Down

0 comments on commit 9d13afe

Please sign in to comment.