-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pages i18n catch-all issue (#582)
* fix pages i18n catch-all issue * collect locales during the build process * add e2e for pages-issue-578
- Loading branch information
1 parent
8fc1597
commit d0a2edd
Showing
27 changed files
with
5,166 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Metadata generated by the next-on-pages build process | ||
*/ | ||
type NextOnPagesBuildMetadata = { | ||
/** Locales used by the application (collected from the Vercel output) */ | ||
collectedLocales: string[]; | ||
}; |
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
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
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,34 @@ | ||
import { getAssertVisible } from '@features-utils/getAssertVisible'; | ||
import { describe, test } from 'vitest'; | ||
|
||
describe('issue-578', () => { | ||
test('navigating to /api/hello should return a Hello world response', async ({ | ||
expect, | ||
}) => { | ||
const response = await fetch(`${DEPLOYMENT_URL}/api/hello`); | ||
expect(await response.text()).toBe('Hello world'); | ||
}); | ||
|
||
test('/ should display the catch-all page', async () => { | ||
const page = await BROWSER.newPage(); | ||
const assertVisible = getAssertVisible(page); | ||
const pageUrl = `${DEPLOYMENT_URL}/`; | ||
await page.goto(pageUrl); | ||
await assertVisible('h1', { hasText: '[[...path]].tsx Page' }); | ||
}); | ||
|
||
test('/a/random/path should display the catch-all page', async () => { | ||
const page = await BROWSER.newPage(); | ||
const assertVisible = getAssertVisible(page); | ||
const pageUrl = `${DEPLOYMENT_URL}/a/random/path`; | ||
await page.goto(pageUrl); | ||
await assertVisible('h1', { hasText: '[[...path]].tsx Page' }); | ||
}); | ||
|
||
test('static assets should be correctly served', async ({ expect }) => { | ||
const response = await fetch(`${DEPLOYMENT_URL}/next.svg`); | ||
expect(await response.text()).toMatch( | ||
/^<svg xmlns="http:\/\/www.w3.org\/2000\/svg" fill="none" viewBox="0 0 394 80">.*<\/svg>/, | ||
); | ||
}); | ||
}); |
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 @@ | ||
{ | ||
"setup": "node --loader tsm setup.ts" | ||
} |
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 @@ | ||
// no setup required |
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,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
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 @@ | ||
Reproduction of https://github.com/cloudflare/next-on-pages/issues/578 |
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,13 @@ | ||
{ | ||
"features": [ | ||
"pages-issue-578" | ||
], | ||
"localSetup": "./setup.sh", | ||
"buildConfig": { | ||
"buildCommand": "npx --force ../../../packages/next-on-pages", | ||
"buildOutputDirectory": ".vercel/output/static" | ||
}, | ||
"deploymentConfig": { | ||
"compatibilityFlags": ["nodejs_compat"] | ||
} | ||
} |
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,10 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
i18n: { | ||
locales: ['en', 'dario', 'testttttt'], | ||
defaultLocale: 'en', | ||
}, | ||
}; | ||
|
||
module.exports = nextConfig; |
Oops, something went wrong.