Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
/**
 * If the response contains 'set-cookie' headers, this method duplicates them so that they are also set on the
 * local proxying domain. The local domain is localhost by default.
 * @param {string} localDomain The domain in which to set the cookies
 * @param {Response} response The response coming from the proxied endpoint
 */
export const extendSetCookieHeadersForLocalDomain = (localDomain = 'localhost', response) => {
  const cookieSetterHeaders = response.headers['set-cookie'];

  if (Array.isArray(cookieSetterHeaders)) {
    // If not on localhost, prepend the domain with the `.` so it works on subdomains too
    const overriddenDomain = localDomain === 'localhost' ? localDomain : `.${localDomain}`;

    cookieSetterHeaders.forEach(header => {
      const cookieForLocalhost = header.replace(/Domain=.+?;/, `Domain=${overriddenDomain};`);
      cookieSetterHeaders.push(cookieForLocalhost);
    });
  }
};