@@ -17,54 +17,21 @@ module.exports = function proxyMiddlewareFactory({ proxyPort, origin }) {
17
17
target : origin ,
18
18
secure : false ,
19
19
changeOrigin : true ,
20
- // cookieDomainRewrite: 'localhost',
21
- // selfHandleResponse: true,
22
- onProxyRes : ( proxyRes , req , res ) => {
23
- if ( req . url . includes ( '/oauth2/v1/authorize' ) ) {
24
- console . log ( '-------------' )
25
- console . log ( '-------------' )
26
- console . log ( '-------------' )
27
- const cs = proxyRes . headers [ 'set-cookie' ] ;
28
- const cs2 = [ ] ;
29
- for ( const c of cs ) {
30
- let c2 = c ;
31
- c2 = c2 . replace ( '; Secure' , '' ) ;
32
- c2 = c2 + '; Domain=javascript-idx-sdk.okta.com' ;
33
- cs2 . push ( c2 ) ;
34
- }
35
- console . log ( cs2 )
36
- proxyRes . headers [ 'set-cookie' ] = cs2 ;
20
+ selfHandleResponse : true ,
21
+ onProxyRes : responseInterceptor ( async ( responseBuffer , proxyRes , req , res ) => {
22
+ const response = responseBuffer . toString ( 'utf8' ) ;
23
+ let patchedResponse = response ;
24
+ patchedResponse = patchedResponse . replace (
25
+ buildRegexForUri ( origin ) ,
26
+ escapeUri ( `http://localhost:${ proxyPort } ` )
27
+ ) ;
28
+ if ( ! req . url . includes ( '/.well-known' ) ) {
29
+ patchedResponse = patchedResponse . replace (
30
+ new RegExp ( origin , 'g' ) ,
31
+ `http://localhost:${ proxyPort } `
32
+ ) ;
37
33
}
38
- } ,
39
- // onProxyRes: responseInterceptor(async (responseBuffer, proxyRes, req, res) => {
40
- // const response = responseBuffer.toString('utf8');
41
- // let patchedResponse = response;
42
- // // patchedResponse = patchedResponse.replace(
43
- // // buildRegexForUri(origin),
44
- // // escapeUri(`http://localhost:${proxyPort}`)
45
- // // );
46
- // // if (!req.url.includes('/.well-known') ) {
47
- // // patchedResponse = patchedResponse.replace(
48
- // // new RegExp(origin, 'g'),
49
- // // `http://localhost:${proxyPort}`
50
- // // );
51
- // // }
52
- // if (req.url.includes('/oauth2/v1/authorize')) {
53
- // console.log('-------------')
54
- // console.log('-------------')
55
- // console.log('-------------')
56
- // const cs = proxyRes.headers['set-cookie'];
57
- // const cs2 = [];
58
- // for (const c of cs) {
59
- // let c2 = c;
60
- // c2 = c2.replace('; Secure', '');
61
- // c2 = c2 + '; Domain=javascript-idx-sdk.okta.com';
62
- // cs2.push(c2);
63
- // }
64
- // console.log(cs2)
65
- // proxyRes.headers['set-cookie'] = cs2;
66
- // }
67
- // return patchedResponse;
68
- // }),
34
+ return patchedResponse ;
35
+ } ) ,
69
36
} ) ;
70
37
} ;
0 commit comments