File tree 3 files changed +18
-2
lines changed
fixtures/simple-next-app/app/api/url
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,11 @@ export default async (request: Request) => {
23
23
tagsManifest = await getTagsManifest ( )
24
24
25
25
const { getMockedRequestHandlers } = await import ( '../next.cjs' )
26
+ const url = new URL ( request . url )
27
+
26
28
; [ nextHandler ] = await getMockedRequestHandlers ( {
27
- port : 3000 ,
28
- hostname : 'localhost' ,
29
+ port : Number ( url . port ) || 443 ,
30
+ hostname : url . hostname ,
29
31
dir : process . cwd ( ) ,
30
32
isDev : false ,
31
33
} )
Original file line number Diff line number Diff line change
1
+ import { NextResponse } from 'next/server'
2
+
3
+ export async function GET ( request ) {
4
+ return NextResponse . json ( { url : request . url } )
5
+ }
Original file line number Diff line number Diff line change @@ -84,3 +84,12 @@ test<FixtureTestContext>('stale-while-revalidate headers should be normalized to
84
84
const index = await invokeFunction ( ctx , { url : '/' } )
85
85
expect ( index . headers ?. [ 'netlify-cdn-cache-control' ] ) . toContain ( 'stale-while-revalidate=31536000' )
86
86
} )
87
+
88
+ test < FixtureTestContext > ( 'handlers receive correct site domain' , async ( ctx ) => {
89
+ await createFixture ( 'simple-next-app' , ctx )
90
+ await runPlugin ( ctx )
91
+ const index = await invokeFunction ( ctx , { url : '/api/url' } )
92
+ const data = JSON . parse ( index . body )
93
+ const url = new URL ( data . url )
94
+ expect ( url . hostname ) . toBe ( 'example.netlify' )
95
+ } )
You can’t perform that action at this time.
0 commit comments