S
S
Stan_12019-03-24 10:43:21
Node.js
Stan_1, 2019-03-24 10:43:21

Why is req.headers encoding wrong?

I can not solve the problem for the second day. I am writing a project on Nuxt.js. I call NextServerInit, and from it I send http headers to the server. And the essence of the problem is that Russian letters are in the wrong encoding. It seems to be like utf8 converted to windows-1252. Here's what it looks like.

{                                                                                                        10:38:04
  host: 'v2.dev.xn--80aaepkoa4atsc1i0b.xn--p1ai',
  'x-forwarded-proto': 'https',
  connection: 'close',
  'x-real-ip': '46.242.10.108',
  'x-geoip-country-code': 'RU',
  'x-geoip-country-name': 'Russia',
  'x-geoip-country-name-ru': 'РоÑÑиÑ',
  'x-geoip-region': 'MOW',
  'x-geoip-city': 'Moscow',
  'x-geoip-city-ru': 'ÐоÑква',
  'x-geoip-postal-code': '101194',
  'x-geoip-latitude': '55.74850',
  'x-geoip-longitude': '37.61840'
}

It seems to have empirically established that this is not a feature of nuxt, but comes from somewhere in Node, from some libraries that process this at a low level. But where it occurs - and did not understand. The code that displays the headers is the following:
export const actions = {
  async nuxtServerInit({commit}, {redirect, req}) {
    console.log(req.headers);
    return axios.post(API_ENDPOINT, ....);
  }

Tell me where to dig this story? What to set up to see normal Russian utf letters?
PS: The ngnix settings are definitely correct. The same variables are used by the Rails project, which correctly sees Russian city names in utf-8 encoding.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question