-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
can jump 404 when that page does not exist (#5701)
- Loading branch information
1 parent
21a55b3
commit 9869f2f
Showing
11 changed files
with
99 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,5 @@ | ||
--- | ||
'@astrojs/node': patch | ||
--- | ||
|
||
Support custom 404 page in standalone mode |
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
9 changes: 9 additions & 0 deletions
9
packages/integrations/node/test/fixtures/node-middleware/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/node-middleware", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/node": "workspace:*" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/integrations/node/test/fixtures/node-middleware/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,13 @@ | ||
--- | ||
--- | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>404</title> | ||
</head> | ||
<body><h1>404!!!!!!!!!!</h1></body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
packages/integrations/node/test/fixtures/node-middleware/src/pages/index.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,11 @@ | ||
--- | ||
--- | ||
|
||
<html lang="en"> | ||
<head><title>node-middleware</title></head> | ||
<style> | ||
</style> | ||
<body> | ||
<div>1</div> | ||
</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,37 @@ | ||
import nodejs from '../dist/index.js'; | ||
import { loadFixture , createRequestAndResponse} from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
|
||
describe('test 404 cant load', () => { | ||
let fixture; | ||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/node-middleware/', | ||
output: 'server', | ||
adapter: nodejs({ mode: 'standalone' }), | ||
}); | ||
await fixture.build(); | ||
}); | ||
describe('test 404', async () => { | ||
let devPreview; | ||
|
||
before(async () => { | ||
devPreview = await fixture.preview(); | ||
}); | ||
after(async () => { | ||
await devPreview.stop(); | ||
}); | ||
it('when mode is standalone', async () => { | ||
const res = await fixture.fetch('/error-page'); | ||
|
||
expect(res.status).to.equal(404); | ||
|
||
const html = await res.text(); | ||
const $ = cheerio.load(html); | ||
|
||
const h1 = $('h1'); | ||
expect(h1.text()).to.equal('404!!!!!!!!!!'); | ||
}); | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.