@@ -105,17 +105,16 @@ app.use(
105105 createProxyMiddleware ( {
106106 target : process . env . PATIENT_SERVICE_URL || 'http://localhost:3001' ,
107107 changeOrigin : true ,
108- pathRewrite : ( path ) => `/admissions${ path } ` ,
108+ pathRewrite : ( path ) =>
109+ `/admissions${ path } ` . replace ( / \/ $ / , '' ) || '/admissions' ,
109110 on : {
110111 error : ( err : any , req : any , res : any ) => {
111112 console . error ( '[Gateway] /admissions proxy error:' , err . message ) ;
112113 if ( ! res . headersSent ) {
113- res
114- . status ( 502 )
115- . json ( {
116- error : 'Patient service unavailable' ,
117- details : err . message ,
118- } ) ;
114+ res . status ( 502 ) . json ( {
115+ error : 'Patient service unavailable' ,
116+ details : err . message ,
117+ } ) ;
119118 }
120119 } ,
121120 } ,
@@ -140,17 +139,16 @@ app.use(
140139 createProxyMiddleware ( {
141140 target : process . env . PATIENT_SERVICE_URL || 'http://localhost:3001' ,
142141 changeOrigin : true ,
143- pathRewrite : ( path ) => `/appointments${ path } ` ,
142+ pathRewrite : ( path ) =>
143+ `/appointments${ path } ` . replace ( / \/ $ / , '' ) || '/appointments' ,
144144 on : {
145145 error : ( err : any , req : any , res : any ) => {
146146 console . error ( '[Gateway] /appointments proxy error:' , err . message ) ;
147147 if ( ! res . headersSent ) {
148- res
149- . status ( 502 )
150- . json ( {
151- error : 'Patient service unavailable' ,
152- details : err . message ,
153- } ) ;
148+ res . status ( 502 ) . json ( {
149+ error : 'Patient service unavailable' ,
150+ details : err . message ,
151+ } ) ;
154152 }
155153 } ,
156154 } ,
0 commit comments