Skip to content

Commit

Permalink
Merge pull request #2174 from Hyperkid123/interceptor-gating
Browse files Browse the repository at this point in the history
fix(proxy): gate feo proxy interceptors
  • Loading branch information
Hyperkid123 authored Feb 26, 2025
2 parents 6d9b3d5 + ed9c32f commit d614995
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/config-utils/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const proxy = ({
// this should reading the aggregated bundles filed generated from chrome service
// The functionality is disabled until the interceptor is ready
// eslint-disable-next-line no-constant-condition
if (isInterceptAbleRequest(req.url)) {
if (FEOFeaturesEnabled && frontendCrdRef.current && isInterceptAbleRequest(req.url)) {
// stub the original write function
const _write = res.write;
let body = '';
Expand All @@ -248,14 +248,10 @@ const proxy = ({

res.write = function () {
try {
if (FEOFeaturesEnabled && frontendCrdRef.current) {
const payload = modifyRequest(body, req.url, frontendCrdRef.current);
// content length is necessary to update to prevent JSON parsing errors in browser
res.setHeader('content-length', payload.length);
_write.call(res, payload, 'utf8');
} else {
_write.call(res, body, 'utf8');
}
const payload = modifyRequest(body, req.url, frontendCrdRef.current!);
// content length is necessary to update to prevent JSON parsing errors in browser
res.setHeader('content-length', payload.length);
_write.call(res, payload, 'utf8');
return true;
} catch {
// wait for all the chunks to arrive
Expand Down

0 comments on commit d614995

Please sign in to comment.