-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vercel): fallback to static 404.html (#9648)
- Loading branch information
Showing
10 changed files
with
87 additions
and
3 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,5 @@ | ||
--- | ||
"@astrojs/vercel": patch | ||
--- | ||
|
||
Fixes an issue where the serverless function could not respond with a prerendered 404 page. |
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
7 changes: 7 additions & 0 deletions
7
packages/integrations/vercel/test/fixtures/prerendered-error-pages/astro.config.mjs
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 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import vercel from '@astrojs/vercel/serverless'; | ||
|
||
export default defineConfig({ | ||
output: 'server', | ||
adapter: vercel() | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/integrations/vercel/test/fixtures/prerendered-error-pages/package.json
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,9 @@ | ||
{ | ||
"name": "@test/astro-vercel-prerendered-error-pages", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/vercel": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/integrations/vercel/test/fixtures/prerendered-error-pages/src/pages/404.astro
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,4 @@ | ||
--- | ||
export const prerender = true | ||
--- | ||
<h1>404</h1> |
8 changes: 8 additions & 0 deletions
8
packages/integrations/vercel/test/fixtures/prerendered-error-pages/src/pages/one.astro
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,8 @@ | ||
<html> | ||
<head> | ||
<title>One</title> | ||
</head> | ||
<body> | ||
<h1>One</h1> | ||
</body> | ||
</html> |
8 changes: 8 additions & 0 deletions
8
packages/integrations/vercel/test/fixtures/prerendered-error-pages/src/pages/two.astro
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,8 @@ | ||
<html> | ||
<head> | ||
<title>Two</title> | ||
</head> | ||
<body> | ||
<h1>Two</h1> | ||
</body> | ||
</html> |
23 changes: 23 additions & 0 deletions
23
packages/integrations/vercel/test/prerendered-error-pages.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,23 @@ | ||
import { loadFixture } from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('prerendered error pages routing', () => { | ||
/** @type {import('./test-utils.js').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/prerendered-error-pages/', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('falls back to 404.html', async () => { | ||
const deploymentConfig = JSON.parse(await fixture.readFile('../.vercel/output/config.json')); | ||
expect(deploymentConfig.routes.at(-1)).to.deep.include({ | ||
src: '/.*', | ||
dest: '/404.html', | ||
status: 404, | ||
}); | ||
}); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.