Skip to content

Commit 8e6d28f

Browse files
Revert "try set-cookies"
This reverts commit 57ebb4b.
1 parent 49973ce commit 8e6d28f

File tree

1 file changed

+15
-48
lines changed

1 file changed

+15
-48
lines changed

test/apps/app/server/proxyMiddleware.js

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,21 @@ module.exports = function proxyMiddlewareFactory({ proxyPort, origin }) {
1717
target: origin,
1818
secure: false,
1919
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+
);
3733
}
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+
}),
6936
});
7037
};

0 commit comments

Comments
 (0)