-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: App Router with assetPrefix: / (#49622)
This is a follow-up PR for #49403. #49403 validates `assetPrefix` is not a relative path. But App Router throws an error with the `assetPrefix: "/"` option. So I've fixed this. <img width="964" alt="Screenshot 2023-05-10 at 23 41 56" src="https://github.com/vercel/next.js/assets/250407/6e83cb57-468c-46d6-a91a-747ad39d6c3c"> `assetPrefix: "/"` has no meaning, but it shouldn't fail.
- Loading branch information
Showing
5 changed files
with
60 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const metadata = { | ||
title: 'Next.js', | ||
description: 'Generated by Next.js', | ||
} | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
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,3 @@ | ||
export default function Index(props) { | ||
return <p id="title">IndexPage</p> | ||
} |
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,3 @@ | ||
module.exports = { | ||
assetPrefix: '/', | ||
} |
35 changes: 35 additions & 0 deletions
35
test/integration/app-config-asset-prefix/test/index.test.js
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,35 @@ | ||
/* eslint-env jest */ | ||
import { join } from 'path' | ||
import { | ||
killApp, | ||
findPort, | ||
launchApp, | ||
hasRedbox, | ||
waitFor, | ||
} from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
|
||
const appDir = join(__dirname, '../') | ||
|
||
describe('App assetPrefix config', () => { | ||
let appPort | ||
let app | ||
|
||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort) | ||
}) | ||
afterAll(() => killApp(app)) | ||
|
||
it('should render correctly with assetPrefix: "/"', async () => { | ||
const browser = await webdriver(appPort, '/') | ||
try { | ||
await waitFor(2000) | ||
expect(await hasRedbox(browser, false)).toBe(false) | ||
const title = await browser.elementById('title').text() | ||
expect(title).toBe('IndexPage') | ||
} finally { | ||
await browser.close() | ||
} | ||
}) | ||
}) |