File tree Expand file tree Collapse file tree 4 files changed +54
-0
lines changed
packages/integrations/netlify Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ export async function createRedirects(
16
16
if ( route . pathname ) {
17
17
_redirects += `
18
18
${ route . pathname } /.netlify/${ kind } /${ entryFile } 200` ;
19
+
20
+ if ( route . route === '/404' ) {
21
+ _redirects += `
22
+ /* /.netlify/${ kind } /${ entryFile } 404` ;
23
+ }
19
24
} else {
20
25
const pattern =
21
26
'/' + route . segments . map ( ( [ part ] ) => ( part . dynamic ? '*' : part . content ) ) . join ( '/' ) ;
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai' ;
2
+ import netlifyAdapter from '../../dist/index.js' ;
3
+ import { loadFixture , testIntegration } from './test-utils.js' ;
4
+
5
+ describe ( '404 page' , ( ) => {
6
+ /** @type {import('./test-utils').Fixture } */
7
+ let fixture ;
8
+
9
+ before ( async ( ) => {
10
+ fixture = await loadFixture ( {
11
+ root : new URL ( './fixtures/404/' , import . meta. url ) . toString ( ) ,
12
+ output : 'server' ,
13
+ adapter : netlifyAdapter ( {
14
+ dist : new URL ( './fixtures/404/dist/' , import . meta. url ) ,
15
+ } ) ,
16
+ site : `http://example.com` ,
17
+ integrations : [ testIntegration ( ) ] ,
18
+ } ) ;
19
+ await fixture . build ( ) ;
20
+ } ) ;
21
+
22
+ it ( '404 route is included in the redirect file' , async ( ) => {
23
+ const redir = await fixture . readFile ( '/_redirects' ) ;
24
+ const expr = new RegExp ( "/* /.netlify/functions/entry 404" ) ;
25
+ expect ( redir ) . to . match ( expr ) ;
26
+ } ) ;
27
+ } ) ;
Original file line number Diff line number Diff line change
1
+ ---
2
+
3
+ ---
4
+ <html >
5
+ <head >
6
+ <title >Not found</title >
7
+ </head >
8
+ <body >
9
+ <h1 >Not found</h1 >
10
+ </body >
11
+ </html >
Original file line number Diff line number Diff line change
1
+ ---
2
+
3
+ ---
4
+ <html >
5
+ <head >
6
+ <title >Testing</title >
7
+ </head >
8
+ <body >
9
+ <h1 >Testing</h1 >
10
+ </body >
11
+ </html >
You can’t perform that action at this time.
0 commit comments