Axios-module: proxyHeadersIgnore not working

Created on 31 Aug 2018  路  3Comments  路  Source: nuxt-community/axios-module

Version

v5.1.0

Reproduction link

https://jsfiddle.net/9d3cksm7/

Steps to reproduce

-

What is expected ?

Headers cf-ray and cf-connecting-ip should be removed.

What is actually happening?

Headers cf-ray and cf-connecting-ip are still present in the proxyReq.

Additional comments?

I have the following nuxt.confg.js:

require('dotenv').config()

module.exports = {
  /*
  ** Build configuration
  */
  build: {
    /*
    ** Run ESLint on save
    */
    extend (config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
    },
    postcss: {
      plugins: {
        'postcss-custom-properties': {
          warnings: false
        }
      }
    }
  },
  /*
  ** CSS dependencies
  */
  css: [
    'bulma',
    '@/assets/sass/main.scss'
  ],
  /*
  ** Headers of the page
  */
  head: {
    title: 'Test',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: 'Test' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  /*
  ** Customize the progress bar color
  */
  loading: { color: '#3B8070' },
  /*
  ** Nuxt.js extensions
  */
  modules: [
    [
      '@nuxtjs/proxy',
      {
        onProxyReq (proxyReq, req, res) {
          console.log(proxyReq)
        }
      }
    ],
    '@nuxtjs/axios',
    '@nuxtjs/auth',
    '@nuxtjs/dotenv',
    [ '@nuxtjs/google-tag-manager', { id: 'GTM-XXXXXXX' } ]
  ],
  /*
  ** Extend auto-generated routes
  */
  plugins: [
    '~/plugins/axios'
  ],
  /*
  ** Extend auto-generated routes
  */
  router: {
    middleware: [ 'auth' ]
  },
  /*
  ** @nuxtjs/options Options
  */
  axios: {
    proxy: true,
    proxyHeadersIgnore: ['host', 'accept', 'cf-ray', 'cf-connecting-ip']
  },
  proxy: {
    '/api/': { target: process.env.API_ENDPOINT, pathRewrite: { '^/api/': '' } }
  },
  /*
  ** @nuxtjs/auth Options
  */
  auth: {
    redirect: {
      login: '/auth/login',
      logout: '/auth/login',
      user: '/'
    },
    strategies: {
      local: {
        endpoints: {
          login: { url: '/api/v1/authentication', propertyName: 'accessToken' },
          user: { url: '/api/v1/me', propertyName: 'email' },
          logout: false
        }
      }
    },
    tokenRequired: true,
    fullPathRedirect: true
  }
}

The proxyIgnoreHeaders are being ignored because the onProxyReq still shows them and also because cloudflare is showing me the Error: 1000.

My package.json is the following:

{
  "name": "some-ui",
  "version": "1.0.0",
  "description": "Test",
  "author": "",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  },
  "dependencies": {
    "@nuxtjs/auth": "^4.5.1",
    "@nuxtjs/axios": "^5.3.1",
    "@nuxtjs/dotenv": "^1.1.1",
    "@nuxtjs/google-tag-manager": "^1.1.0",
    "bulma": "^0.7.0",
    "clipboard": "^2.0.0",
    "ibantools": "^2.0.0",
    "isemail": "^3.1.2",
    "jsvat": "^1.2.3",
    "nuxt": "^1.4.2",
    "ramda": "^0.25.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.6",
    "eslint": "^4.15.0",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-vue": "^4.7.1",
    "node-sass": "^4.9.3",
    "sass-loader": "^7.1.0"
  }
}

Can anyone help me with this please?

This bug report is available on Nuxt community (#c160)
bug-report

All 3 comments

I've changed my nuxt config to include the following:

    [
      '@nuxtjs/proxy',
      {
        onProxyReq (proxyReq, req, res) {
          console.log('proxyReq', proxyReq)
          console.log('req', req.headers)
          console.log('res', res.headers)
        },
        onProxyRes (proxyRes, req, res) {
          console.log('proxyRes', proxyRes)
          console.log('req', req.headers)
          console.log('res', res.headers)
        },
        headers: {
          'xz-foo': 'bar'
        }
      }
    ],

This is what I got:
proxyReq ClientRequest { domain: null, _events: { socket: [Function], error: [ [Function: onerror], [Function: proxyError] ], unpipe: [Function: onunpipe], drain: [Function], close: { [Function: bound onceWrapper] listener: [Function: onclose] }, finish: { [Function: bound onceWrapper] listener: [Function: onfinish] }, response: [Function] }, _eventsCount: 7, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: false, _headerSent: false, socket: TLSSocket { _tlsOptions: { pipe: false, secureContext: [Object], isServer: false, requestCert: true, rejectUnauthorized: true, session: undefined, NPNProtocols: undefined, ALPNProtocols: undefined, requestOCSP: undefined }, _secureEstablished: false, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: null, alpnProtocol: null, authorized: false, authorizationError: null, encrypted: true, _events: { close: [Array], end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], secureConnect: [Object], connect: [Array], secure: [Function], free: [Function: onFree], agentRemove: [Function: onRemove], drain: [Function: ondrain], error: [Function: socketErrorListener], data: [Function: socketOnData] }, _eventsCount: 12, connecting: true, _hadError: false, _handle: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: false, owner: [Circular], onread: [Function: onread], writeQueueSize: 1, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _parent: null, _host: 'api.beta.foo.io', _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: true, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: false, _bytesDispatched: 0, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: false, owner: [Circular], onread: [Function: onread], writeQueueSize: 1, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _requestCert: true, _rejectUnauthorized: true, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': null, _headers: [], _url: '', _consumed: false, socket: [Circular], incoming: null, outgoing: [Circular], maxHeaderPairs: 2000, onIncoming: [Function: parserOnIncomingClient] }, _httpMessage: [Circular], [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, connection: TLSSocket { _tlsOptions: { pipe: false, secureContext: [Object], isServer: false, requestCert: true, rejectUnauthorized: true, session: undefined, NPNProtocols: undefined, ALPNProtocols: undefined, requestOCSP: undefined }, _secureEstablished: false, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: null, alpnProtocol: null, authorized: false, authorizationError: null, encrypted: true, _events: { close: [Array], end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], secureConnect: [Object], connect: [Array], secure: [Function], free: [Function: onFree], agentRemove: [Function: onRemove], drain: [Function: ondrain], error: [Function: socketErrorListener], data: [Function: socketOnData] }, _eventsCount: 12, connecting: true, _hadError: false, _handle: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: false, owner: [Circular], onread: [Function: onread], writeQueueSize: 1, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _parent: null, _host: 'api.beta.foo.io', _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: true, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: false, _bytesDispatched: 0, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: false, owner: [Circular], onread: [Function: onread], writeQueueSize: 1, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _requestCert: true, _rejectUnauthorized: true, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': null, _headers: [], _url: '', _consumed: false, socket: [Circular], incoming: null, outgoing: [Circular], maxHeaderPairs: 2000, onIncoming: [Function: parserOnIncomingClient] }, _httpMessage: [Circular], [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, _header: null, _onPendingData: [Function: noopPendingOutput], agent: Agent { domain: null, _events: { free: [Function] }, _eventsCount: 1, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: { path: null }, requests: {}, sockets: { 'api.beta.foo.io:443:::::::true::': [Array] }, freeSockets: {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, maxCachedSessions: 100, _sessionCache: { map: {}, list: [] } }, socketPath: undefined, timeout: undefined, method: 'POST', path: '/v1/authentication', _ended: false, res: null, aborted: undefined, timeoutCb: null, upgradeOrConnect: false, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': null, _headers: [], _url: '', _consumed: false, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: false, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: null, alpnProtocol: null, authorized: false, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 12, connecting: true, _hadError: false, _handle: [Object], _parent: null, _host: 'api.beta.foo.io', _readableState: [Object], readable: true, domain: null, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: false, _bytesDispatched: 0, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [Object], _requestCert: true, _rejectUnauthorized: true, parser: [Circular], _httpMessage: [Circular], [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, incoming: null, outgoing: [Circular], maxHeaderPairs: 2000, onIncoming: [Function: parserOnIncomingClient] }, maxHeadersCount: null, cookie: [ 'cookie', '__cfduid=d82ea5fae739e603d3d5dea4a65728dfe1535716113; auth.strategy=local; auth._token.local=false; auth._refresh_token.local=false' ], 'accept-language': [ 'accept-language', 'en-US,en;q=0.9,fi;q=0.8,pt;q=0.7,es;q=0.6' ], referer: [ 'referer', 'https://bar-qp.foo.io/auth/login' ], 'content-type': [ 'content-type', 'application/json;charset=UTF-8' ], 'user-agent': [ 'user-agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' ], origin: [ 'origin', 'https://bar-qp.foo.io' ], accept: [ 'accept', 'application/json, text/plain, */*' ], 'cf-visitor': [ 'cf-visitor', '{"scheme":"https"}' ], 'cf-ray': [ 'cf-ray', '452f4891ce68a86f-CDG' ], 'cf-ipcountry': [ 'cf-ipcountry', 'XX' ], 'accept-encoding': [ 'accept-encoding', 'gzip' ], 'content-length': [ 'content-length', '43' ], 'x-original-forwarded-for': [ 'x-original-forwarded-for', '35.205.77.74' ], 'x-scheme': [ 'x-scheme', 'https' ], 'x-original-uri': [ 'x-original-uri', '/api/v1/authentication' ], 'x-forwarded-proto': [ 'x-forwarded-proto', 'https' ], 'x-forwarded-port': [ 'x-forwarded-port', '443' ], 'x-forwarded-host': [ 'x-forwarded-host', 'bar-qp.foo.io' ], 'x-forwarded-for': [ 'x-forwarded-for', '35.205.77.74' ], 'x-real-ip': [ 'x-real-ip', '35.205.77.74' ], 'x-request-id': [ 'x-request-id', 'd08b0082b00ef668a66aaf6b20ff0fa0' ], connection: [ 'connection', 'close' ], host: [ 'host', 'api.beta.foo.io' ], 'xz-foo': [ 'xz-foo', 'bar' ] } } req { host: 'bar-qp.foo.io', connection: 'close', 'x-request-id': 'd08b0082b00ef668a66aaf6b20ff0fa0', 'x-real-ip': '35.205.77.74', 'x-forwarded-for': '35.205.77.74', 'x-forwarded-host': 'bar-qp.foo.io', 'x-forwarded-port': '443', 'x-forwarded-proto': 'https', 'x-original-uri': '/api/v1/authentication', 'x-scheme': 'https', 'x-original-forwarded-for': '35.205.77.74', 'content-length': '43', 'accept-encoding': 'gzip', 'cf-ipcountry': 'XX', 'cf-ray': '452f4891ce68a86f-CDG', 'cf-visitor': '{"scheme":"https"}', accept: 'application/json, text/plain, */*', origin: 'https://bar-qp.foo.io', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'content-type': 'application/json;charset=UTF-8', referer: 'https://bar-qp.foo.io/auth/login', 'accept-language': 'en-US,en;q=0.9,fi;q=0.8,pt;q=0.7,es;q=0.6', cookie: '__cfduid=d82ea5fae739e603d3d5dea4a65728dfe1535716113; auth.strategy=local; auth._token.local=false; auth._refresh_token.local=false', 'cf-connecting-ip': '35.205.77.74' } res undefined proxyRes IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: null, pipesCount: 0, flowing: null, ended: false, endEmitted: false, reading: false, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: true, decoder: null, encoding: null }, readable: true, domain: null, _events: { end: [Function: responseOnEnd] }, _eventsCount: 1, _maxListeners: undefined, socket: TLSSocket { _tlsOptions: { pipe: false, secureContext: [Object], isServer: false, requestCert: true, rejectUnauthorized: true, session: undefined, NPNProtocols: undefined, ALPNProtocols: undefined, requestOCSP: undefined }, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: 'api.beta.foo.io', npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: { close: [Array], end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], secure: [Function], free: [Function: onFree], agentRemove: [Function: onRemove], drain: [Function: ondrain], error: [Function: socketErrorListener], data: [Function: socketOnData] }, _eventsCount: 10, connecting: false, _hadError: false, _handle: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: true, owner: [Circular], onread: [Function: onread], writeQueueSize: 0, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _parent: null, _host: 'api.beta.foo.io', _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: false, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: false, _bytesDispatched: 1071, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: true, owner: [Circular], onread: [Function: onread], writeQueueSize: 0, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _requestCert: true, _rejectUnauthorized: true, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': null, _headers: [], _url: '', _consumed: false, socket: [Circular], incoming: [Circular], outgoing: [Object], maxHeaderPairs: 2000, onIncoming: [Function: parserOnIncomingClient] }, _httpMessage: ClientRequest { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [Circular], connection: [Circular], _header: 'POST /v1/authentication HTTP/1.1\r\ncf-connecting-ip: 35.205.77.74\r\ncookie: __cfduid=d82ea5fae739e603d3d5dea4a65728dfe1535716113; auth.strategy=local; auth._token.local=false; auth._refresh_token.local=false\r\naccept-language: en-US,en;q=0.9,fi;q=0.8,pt;q=0.7,es;q=0.6\r\nreferer: https://bar-qp.foo.io/auth/login\r\ncontent-type: application/json;charset=UTF-8\r\nuser-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\r\norigin: https://bar-qp.foo.io\r\naccept: application/json, text/plain, */*\r\ncf-visitor: {"scheme":"https"}\r\ncf-ray: 452f4891ce68a86f-CDG\r\ncf-ipcountry: XX\r\naccept-encoding: gzip\r\ncontent-length: 43\r\nx-original-forwarded-for: 35.205.77.74\r\nx-scheme: https\r\nx-original-uri: /api/v1/authentication\r\nx-forwarded-proto: https\r\nx-forwarded-port: 443\r\nx-forwarded-host: bar-qp.foo.io\r\nx-forwarded-for: 35.205.77.74\r\nx-real-ip: 35.205.77.74\r\nx-request-id: d08b0082b00ef668a66aaf6b20ff0fa0\r\nconnection: close\r\nhost: api.beta.foo.io\r\nxz-foo: bar\r\n\r\n', _onPendingData: [Function: noopPendingOutput], agent: [Object], socketPath: undefined, timeout: undefined, method: 'POST', path: '/v1/authentication', _ended: false, res: [Circular], aborted: undefined, timeoutCb: null, upgradeOrConnect: false, parser: [Object], maxHeadersCount: null, [Symbol(outHeadersKey)]: [Object] }, [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, connection: TLSSocket { _tlsOptions: { pipe: false, secureContext: [Object], isServer: false, requestCert: true, rejectUnauthorized: true, session: undefined, NPNProtocols: undefined, ALPNProtocols: undefined, requestOCSP: undefined }, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: 'api.beta.foo.io', npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: { close: [Array], end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], secure: [Function], free: [Function: onFree], agentRemove: [Function: onRemove], drain: [Function: ondrain], error: [Function: socketErrorListener], data: [Function: socketOnData] }, _eventsCount: 10, connecting: false, _hadError: false, _handle: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: true, owner: [Circular], onread: [Function: onread], writeQueueSize: 0, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _parent: null, _host: 'api.beta.foo.io', _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: false, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: false, _bytesDispatched: 1071, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: true, owner: [Circular], onread: [Function: onread], writeQueueSize: 0, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _requestCert: true, _rejectUnauthorized: true, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': null, _headers: [], _url: '', _consumed: false, socket: [Circular], incoming: [Circular], outgoing: [Object], maxHeaderPairs: 2000, onIncoming: [Function: parserOnIncomingClient] }, _httpMessage: ClientRequest { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [Circular], connection: [Circular], _header: 'POST /v1/authentication HTTP/1.1\r\ncf-connecting-ip: 35.205.77.74\r\ncookie: __cfduid=d82ea5fae739e603d3d5dea4a65728dfe1535716113; auth.strategy=local; auth._token.local=false; auth._refresh_token.local=false\r\naccept-language: en-US,en;q=0.9,fi;q=0.8,pt;q=0.7,es;q=0.6\r\nreferer: https://bar-qp.foo.io/auth/login\r\ncontent-type: application/json;charset=UTF-8\r\nuser-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\r\norigin: https://bar-qp.foo.io\r\naccept: application/json, text/plain, */*\r\ncf-visitor: {"scheme":"https"}\r\ncf-ray: 452f4891ce68a86f-CDG\r\ncf-ipcountry: XX\r\naccept-encoding: gzip\r\ncontent-length: 43\r\nx-original-forwarded-for: 35.205.77.74\r\nx-scheme: https\r\nx-original-uri: /api/v1/authentication\r\nx-forwarded-proto: https\r\nx-forwarded-port: 443\r\nx-forwarded-host: bar-qp.foo.io\r\nx-forwarded-for: 35.205.77.74\r\nx-real-ip: 35.205.77.74\r\nx-request-id: d08b0082b00ef668a66aaf6b20ff0fa0\r\nconnection: close\r\nhost: api.beta.foo.io\r\nxz-foo: bar\r\n\r\n', _onPendingData: [Function: noopPendingOutput], agent: [Object], socketPath: undefined, timeout: undefined, method: 'POST', path: '/v1/authentication', _ended: false, res: [Circular], aborted: undefined, timeoutCb: null, upgradeOrConnect: false, parser: [Object], maxHeadersCount: null, [Symbol(outHeadersKey)]: [Object] }, [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: false, headers: { date: 'Fri, 31 Aug 2018 11:51:08 GMT', 'content-type': 'text/html; charset=UTF-8', 'transfer-encoding': 'chunked', connection: 'close', 'cache-control': 'max-age=8', expires: 'Fri, 31 Aug 2018 11:51:16 GMT', 'x-frame-options': 'SAMEORIGIN', vary: 'Accept-Encoding', server: 'cloudflare-nginx', 'cf-ray': '452f48961f3ba875-CDG', 'content-encoding': 'gzip' }, rawHeaders: [ 'Date', 'Fri, 31 Aug 2018 11:51:08 GMT', 'Content-Type', 'text/html; charset=UTF-8', 'Transfer-Encoding', 'chunked', 'Connection', 'close', 'Cache-Control', 'max-age=8', 'Expires', 'Fri, 31 Aug 2018 11:51:16 GMT', 'X-Frame-Options', 'SAMEORIGIN', 'Vary', 'Accept-Encoding', 'Server', 'cloudflare-nginx', 'CF-RAY', '452f48961f3ba875-CDG', 'Content-Encoding', 'gzip' ], trailers: {}, rawTrailers: [], upgrade: false, url: '', method: null, statusCode: 403, statusMessage: 'Forbidden', client: TLSSocket { _tlsOptions: { pipe: false, secureContext: [Object], isServer: false, requestCert: true, rejectUnauthorized: true, session: undefined, NPNProtocols: undefined, ALPNProtocols: undefined, requestOCSP: undefined }, _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: 'api.beta.foo.io', npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: { close: [Array], end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], secure: [Function], free: [Function: onFree], agentRemove: [Function: onRemove], drain: [Function: ondrain], error: [Function: socketErrorListener], data: [Function: socketOnData] }, _eventsCount: 10, connecting: false, _hadError: false, _handle: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: true, owner: [Circular], onread: [Function: onread], writeQueueSize: 0, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _parent: null, _host: 'api.beta.foo.io', _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: false, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: false, _bytesDispatched: 1071, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: TLSWrap { _parent: [Object], _parentWrap: undefined, _secureContext: [Object], reading: true, owner: [Circular], onread: [Function: onread], writeQueueSize: 0, onhandshakestart: [Function], onhandshakedone: [Function], onocspresponse: [Function], onerror: [Function] }, _requestCert: true, _rejectUnauthorized: true, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': null, _headers: [], _url: '', _consumed: false, socket: [Circular], incoming: [Circular], outgoing: [Object], maxHeaderPairs: 2000, onIncoming: [Function: parserOnIncomingClient] }, _httpMessage: ClientRequest { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [Circular], connection: [Circular], _header: 'POST /v1/authentication HTTP/1.1\r\ncf-connecting-ip: 35.205.77.74\r\ncookie: __cfduid=d82ea5fae739e603d3d5dea4a65728dfe1535716113; auth.strategy=local; auth._token.local=false; auth._refresh_token.local=false\r\naccept-language: en-US,en;q=0.9,fi;q=0.8,pt;q=0.7,es;q=0.6\r\nreferer: https://bar-qp.foo.io/auth/login\r\ncontent-type: application/json;charset=UTF-8\r\nuser-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\r\norigin: https://bar-qp.foo.io\r\naccept: application/json, text/plain, */*\r\ncf-visitor: {"scheme":"https"}\r\ncf-ray: 452f4891ce68a86f-CDG\r\ncf-ipcountry: XX\r\naccept-encoding: gzip\r\ncontent-length: 43\r\nx-original-forwarded-for: 35.205.77.74\r\nx-scheme: https\r\nx-original-uri: /api/v1/authentication\r\nx-forwarded-proto: https\r\nx-forwarded-port: 443\r\nx-forwarded-host: bar-qp.foo.io\r\nx-forwarded-for: 35.205.77.74\r\nx-real-ip: 35.205.77.74\r\nx-request-id: d08b0082b00ef668a66aaf6b20ff0fa0\r\nconnection: close\r\nhost: api.beta.foo.io\r\nxz-foo: bar\r\n\r\n', _onPendingData: [Function: noopPendingOutput], agent: [Object], socketPath: undefined, timeout: undefined, method: 'POST', path: '/v1/authentication', _ended: false, res: [Circular], aborted: undefined, timeoutCb: null, upgradeOrConnect: false, parser: [Object], maxHeadersCount: null, [Symbol(outHeadersKey)]: [Object] }, [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, _consuming: false, _dumped: false, req: ClientRequest { domain: null, _events: { socket: [Function], error: [Function: proxyError], response: [Function], prefinish: [Function: requestOnPrefinish] }, _eventsCount: 4, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: 'api.beta.foo.io', npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 10, connecting: false, _hadError: false, _handle: [Object], _parent: null, _host: 'api.beta.foo.io', _readableState: [Object], readable: true, domain: null, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: false, _bytesDispatched: 1071, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [Object], _requestCert: true, _rejectUnauthorized: true, parser: [Object], _httpMessage: [Circular], [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, connection: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: 'api.beta.foo.io', npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 10, connecting: false, _hadError: false, _handle: [Object], _parent: null, _host: 'api.beta.foo.io', _readableState: [Object], readable: true, domain: null, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: false, _bytesDispatched: 1071, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [Object], _requestCert: true, _rejectUnauthorized: true, parser: [Object], _httpMessage: [Circular], [Symbol(asyncId)]: 175, [Symbol(bytesRead)]: 0 }, _header: 'POST /v1/authentication HTTP/1.1\r\ncf-connecting-ip: 35.205.77.74\r\ncookie: __cfduid=d82ea5fae739e603d3d5dea4a65728dfe1535716113; auth.strategy=local; auth._token.local=false; auth._refresh_token.local=false\r\naccept-language: en-US,en;q=0.9,fi;q=0.8,pt;q=0.7,es;q=0.6\r\nreferer: https://bar-qp.foo.io/auth/login\r\ncontent-type: application/json;charset=UTF-8\r\nuser-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\r\norigin: https://bar-qp.foo.io\r\naccept: application/json, text/plain, */*\r\ncf-visitor: {"scheme":"https"}\r\ncf-ray: 452f4891ce68a86f-CDG\r\ncf-ipcountry: XX\r\naccept-encoding: gzip\r\ncontent-length: 43\r\nx-original-forwarded-for: 35.205.77.74\r\nx-scheme: https\r\nx-original-uri: /api/v1/authentication\r\nx-forwarded-proto: https\r\nx-forwarded-port: 443\r\nx-forwarded-host: bar-qp.foo.io\r\nx-forwarded-for: 35.205.77.74\r\nx-real-ip: 35.205.77.74\r\nx-request-id: d08b0082b00ef668a66aaf6b20ff0fa0\r\nconnection: close\r\nhost: api.beta.foo.io\r\nxz-foo: bar\r\n\r\n', _onPendingData: [Function: noopPendingOutput], agent: Agent { domain: null, _events: [Object], _eventsCount: 1, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object], requests: {}, sockets: [Object], freeSockets: {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, maxCachedSessions: 100, _sessionCache: [Object] }, socketPath: undefined, timeout: undefined, method: 'POST', path: '/v1/authentication', _ended: false, res: [Circular], aborted: undefined, timeoutCb: null, upgradeOrConnect: false, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': null, _headers: [], _url: '', _consumed: false, socket: [Object], incoming: [Circular], outgoing: [Circular], maxHeaderPairs: 2000, onIncoming: [Function: parserOnIncomingClient] }, maxHeadersCount: null, [Symbol(outHeadersKey)]: { 'cf-connecting-ip': [Array], cookie: [Array], 'accept-language': [Array], referer: [Array], 'content-type': [Array], 'user-agent': [Array], origin: [Array], accept: [Array], 'cf-visitor': [Array], 'cf-ray': [Array], 'cf-ipcountry': [Array], 'accept-encoding': [Array], 'content-length': [Array], 'x-original-forwarded-for': [Array], 'x-scheme': [Array], 'x-original-uri': [Array], 'x-forwarded-proto': [Array], 'x-forwarded-port': [Array], 'x-forwarded-host': [Array], 'x-forwarded-for': [Array], 'x-real-ip': [Array], 'x-request-id': [Array], connection: [Array], host: [Array], 'xz-foo': [Array] } } } req { host: 'bar-qp.foo.io', connection: 'close', 'x-request-id': 'd08b0082b00ef668a66aaf6b20ff0fa0', 'x-real-ip': '35.205.77.74', 'x-forwarded-for': '35.205.77.74', 'x-forwarded-host': 'bar-qp.foo.io', 'x-forwarded-port': '443', 'x-forwarded-proto': 'https', 'x-original-uri': '/api/v1/authentication', 'x-scheme': 'https', 'x-original-forwarded-for': '35.205.77.74', 'content-length': '43', 'accept-encoding': 'gzip', 'cf-ipcountry': 'XX', 'cf-ray': '452f4891ce68a86f-CDG', 'cf-visitor': '{"scheme":"https"}', accept: 'application/json, text/plain, */*', origin: 'https://bar-qp.foo.io', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'content-type': 'application/json;charset=UTF-8', referer: 'https://bar-qp.foo.io/auth/login', 'accept-language': 'en-US,en;q=0.9,fi;q=0.8,pt;q=0.7,es;q=0.6', cookie: '__cfduid=d82ea5fae739e603d3d5dea4a65728dfe1535716113; auth.strategy=local; auth._token.local=false; auth._refresh_token.local=false', 'cf-connecting-ip': '35.205.77.74' } res undefined

I experience the same issue and was able to help @ealves-pt solve this instance on Discord as well. For anyone else that has this issue:
In you proxy options add this (along with any other headers you want to remove):

onProxyReq: (proxyReq) => {
      proxyReq.removeHeader('cf-visitor')
      proxyReq.removeHeader('cf-ray')
      proxyReq.removeHeader('cf-connecting-ip')
    },

For example this should go here: '/api/': {..someOptions, onProxyReq(..) => { ... }}

Well found the solution with the help of @Jake0oo0.

It seems that the options proxyHeadersIgnore and proxyHeaders: false are pretty useless which turns this into a very misleading situation.

The solution was to change the nuxt.config.js above to:

module.exports = {
  // (...)
  /*
  ** Nuxt.js extensions
  */
  modules: [
    [
      '@nuxtjs/proxy',
      {
        onProxyReq (proxyReq) {
          proxyReq.removeHeader('cf-visitor')
          proxyReq.removeHeader('cf-ray')
          proxyReq.removeHeader('cf-connecting-ip')
        }
      }
    ],
    '@nuxtjs/axios',
    '@nuxtjs/auth',
    '@nuxtjs/dotenv',
    [ '@nuxtjs/google-tag-manager', { id: 'GTM-XXXXXXX' } ]
  ],
  // (...)
  axios: {
    proxy: true,
  },
  proxy: {
    '/api/': { target: process.env.API_ENDPOINT, pathRewrite: { '^/api/': '' } }
  },
  // (...)
}

I will keep this issue open to see if someone can shed some light on why those properties don't work as intended.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

megapctr picture megapctr  路  5Comments

tebaly picture tebaly  路  3Comments

gammpamm picture gammpamm  路  4Comments

artmarydotir picture artmarydotir  路  4Comments

altafsayani picture altafsayani  路  3Comments