File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
fixtures/simple-next-app/app/api/url Expand file tree Collapse file tree 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) => {
2323 tagsManifest = await getTagsManifest ( )
2424
2525 const { getMockedRequestHandlers } = await import ( '../next.cjs' )
26+ const url = new URL ( request . url )
27+
2628 ; [ nextHandler ] = await getMockedRequestHandlers ( {
27- port : 3000 ,
28- hostname : 'localhost' ,
29+ port : Number ( url . port ) || 443 ,
30+ hostname : url . hostname ,
2931 dir : process . cwd ( ) ,
3032 isDev : false ,
3133 } )
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
8484 const index = await invokeFunction ( ctx , { url : '/' } )
8585 expect ( index . headers ?. [ 'netlify-cdn-cache-control' ] ) . toContain ( 'stale-while-revalidate=31536000' )
8686} )
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