-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix manifest load errors when using assetPrefix (#55416)
### What? `_devPagesManifest.json` and `_devMiddlewareManifest.json` will fail to load when using an asset prefix. In conjunction with i18n, this causes the app to get caught in an infinite load loop. ### Why? We're expecting these paths to be exact matches but when there's an assetPrefix specified, they won't be matched. ### How? This copies similar behavior to how we handle [`webpack-hmr`](https://github.com/vercel/next.js/blob/2e2211d27b3f0ff1cff5553453df4cf391996163/packages/next/src/server/lib/router-server.ts#L681) by doing a partial match on the URL when serving it Closes NEXT-1618 Fixes #55389
- Loading branch information
Showing
5 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { join } from 'path' | ||
import { createNextDescribe } from 'e2e-utils' | ||
import { check } from 'next-test-utils' | ||
|
||
createNextDescribe( | ||
'asset-prefix', | ||
{ | ||
files: join(__dirname, 'asset-prefix'), | ||
}, | ||
({ next }) => { | ||
it('should load the app properly without reloading', async () => { | ||
const browser = await next.browser('/') | ||
await browser.eval(`window.__v = 1`) | ||
|
||
expect(await browser.elementByCss('div').text()).toBe('Hello World') | ||
|
||
await check(async () => { | ||
const logs = await browser.log() | ||
const hasError = logs.some((log) => | ||
log.message.includes('Failed to fetch') | ||
) | ||
return hasError ? 'error' : 'success' | ||
}, 'success') | ||
|
||
expect(await browser.eval(`window.__v`)).toBe(1) | ||
}) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const ASSET_PREFIX = 'asset-prefix' | ||
|
||
module.exports = { | ||
assetPrefix: ASSET_PREFIX, | ||
i18n: { | ||
locales: ['en-US'], | ||
defaultLocale: 'en-US', | ||
}, | ||
async rewrites() { | ||
return { | ||
beforeFiles: [ | ||
{ | ||
source: `/:locale/${ASSET_PREFIX}/_next/:path*`, | ||
destination: '/_next/:path*', | ||
locale: false, | ||
}, | ||
], | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react' | ||
|
||
export default function Page() { | ||
return <div>Hello World</div> | ||
} |