Files
next.js/test/development/app-dir/hmr-asset-prefix-full-url/asset-prefix.test.ts
Jiwon ChoiandGitHub 485497d943 chore: remove asset prefix warning log and update docs (#68681)
### Why?

In https://github.com/vercel/next.js/pull/68622 we fixed a bug that HMR
breaks when `assetPrefix` is set to full URL.
The fix was targeted to the edge case where the user may set `localhost`
to the `assetPrefix`, and technically, when the request is valid the HMR
should work.

However, we do not recommend this pattern as the `assetPrefix` is
intended to be used for setting a CDN URL.

### How?

Therefore we modify the docs to gently imply that the `assetPrefix` is
for CDN URL.
Also, removed the warning log that could be confusing whether we support
it or not.
Setting localhost will still work, but we do not mention about it within
the app.
2024-08-09 02:53:49 +09:00

33 lines
895 B
TypeScript

import { createNext } from 'e2e-utils'
import { findPort, retry } from 'next-test-utils'
describe('app-dir assetPrefix full URL', () => {
let next, forcedPort
beforeAll(async () => {
forcedPort = ((await findPort()) ?? '54321').toString()
next = await createNext({
files: __dirname,
forcedPort,
nextConfig: {
assetPrefix: `http://localhost:${forcedPort}`,
},
})
})
afterAll(() => next.destroy())
it('should not break HMR when asset prefix set to full URL', async () => {
const browser = await next.browser('/')
const text = await browser.elementByCss('p').text()
expect(text).toBe('before edit')
await next.patchFile('app/page.tsx', (content) => {
return content.replace('before', 'after')
})
await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('after edit')
})
})
})