Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: response-interceptor.ts #1057

Open
2 tasks done
kogovsekmatic opened this issue Nov 8, 2024 · 0 comments
Open
2 tasks done

FIX: response-interceptor.ts #1057

kogovsekmatic opened this issue Nov 8, 2024 · 0 comments

Comments

@kogovsekmatic
Copy link

kogovsekmatic commented Nov 8, 2024

Checks

Describe the bug (be clear and concise)

function copyHeaders: RegEx for Domain=*; matches only the first character not the whole domain for example Domain=example.com; replaces strips Domain=e but leaves xample.com

Step-by-step reproduction instructions

Using the request interceptor

Expected behavior (be clear and concise)

to strip the entire Domain=*;

How is http-proxy-middleware used in your project?

Proxying things

What http-proxy-middleware configuration are you using?

export const proxyConfig = createProxyMiddleware({
  target,
  changeOrigin: false,
  selfHandleResponse: true,
  on: {
    proxyRes: responseInterceptor(
      async (responseBuffer, proxyRes, req, res) => {
        let response = responseBuffer.toString("utf8");
        // Return
        return response;
      }
    ),
  },
});

What OS/version and node/version are you seeing the problem?

MacOS

Additional context (optional)

keys.forEach((key) => {
  let value = originalResponse.headers[key];
  if (key === "set-cookie") {
    // remove cookie domain
    value = Array.isArray(value) ? value : [value];
    value = value
      .map((x) => x.replace(/Domain=[^;]+;?/i, "")
      .replace(/\s+/g, " "));
  }
  response.setHeader(key, value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant