@@ -3,6 +3,7 @@ import { createEndpoint, type Endpoint } from "./endpoint";
33import { createRouter } from "./router" ;
44import { z } from "zod" ;
55import { APIError } from "./error" ;
6+ import { getRequest } from "./adapters/node/request" ;
67
78describe ( "router" , ( ) => {
89 it ( "should be able to return simple response" , async ( ) => {
@@ -202,6 +203,33 @@ describe("router", () => {
202203 const text = await response . text ( ) ;
203204 expect ( text ) . toBe ( "/test/api/v1/test" ) ;
204205 } ) ;
206+
207+ it ( "node adapter getRequest should include Express baseUrl when present" , async ( ) => {
208+ const base = "http://localhost:3000" ;
209+ const fakeReq : any = {
210+ headers : { host : "localhost:3000" } ,
211+ method : "GET" ,
212+ url : "/auth/callback" ,
213+ baseUrl : "/api" ,
214+ httpVersionMajor : 1 ,
215+ destroyed : false ,
216+ } ;
217+ const req = getRequest ( { base, request : fakeReq } ) ;
218+ expect ( new URL ( req . url ) . href ) . toBe ( "http://localhost:3000/api/auth/callback" ) ;
219+ } ) ;
220+
221+ it ( "node adapter getRequest should fall back to url when baseUrl is missing" , async ( ) => {
222+ const base = "http://localhost:3000" ;
223+ const fakeReq : any = {
224+ headers : { host : "localhost:3000" } ,
225+ method : "GET" ,
226+ url : "/auth/callback" ,
227+ httpVersionMajor : 1 ,
228+ destroyed : false ,
229+ } ;
230+ const req = getRequest ( { base, request : fakeReq } ) ;
231+ expect ( new URL ( req . url ) . href ) . toBe ( "http://localhost:3000/auth/callback" ) ;
232+ } ) ;
205233} ) ;
206234
207235describe ( "route middleware" , ( ) => {
0 commit comments