Nuxt.js: Bug using SSL + $axios modules + asyncData

Created on 12 Jun 2018  路  4Comments  路  Source: nuxt/nuxt.js

Version

v1.4.0

Reproduction link

https://github.com/danielsalles/nuxt-bug-asyncData-Axios

Steps to reproduce

npm install
npm run dev

Open browser:
Acess localhost:3000/usingssr
ctrl+f5
Captura de tela de 2018-06-11 21-43-12.png

Acess localhost:3000/usingnossr
ctrl+f5
Captura de tela de 2018-06-11 21-44-03.png

What is expected ?

The answer is correct === /usingnossr

What is actually happening?

Wrong response === /usingssr

Additional comments?

This bug is referenced to this question (https://cmty.app/nuxt/nuxt.js/issues/c7224).

I'm basically trying to consume an API and I'm not getting it. If it is HTTP (without SSL) it works normally, but I need SSL enabled.

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

Most helpful comment

The server responds with header 'content-encoding': 'br'. Your code works if you clear the 'accept-encoding' header before request:

$axios.setHeader('accept-encoding', false);

Or just 'proxyHeaders: false' in nuxt.config.js:

axios: { proxyHeaders: false }

All 4 comments

The server responds with header 'content-encoding': 'br'. Your code works if you clear the 'accept-encoding' header before request:

$axios.setHeader('accept-encoding', false);

Or just 'proxyHeaders: false' in nuxt.config.js:

axios: { proxyHeaders: false }

@zyxd It worked. But is there any special reason to have to do this in SSR mode?

Thanks!

@danielsalles By default, the 'proxyHeaders' mode is enabled. In this mode @nuxt/axios copies all properties of the 'context.request.headers' to axios request headers. Including 'accept-encoding' if your browser send it.

The Chrome browser sends 'accept-encoding: gzip deflate br', because it can decode all of them. But in JS code you must decode it manually or use 'identity' (raw content) encoding which is default if 'accept-encoding' not specified.

Server to which you send requests supports 'identity' and 'br' encoding as i understand.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieloprado picture danieloprado  路  3Comments

vadimsg picture vadimsg  路  3Comments

uptownhr picture uptownhr  路  3Comments

bimohxh picture bimohxh  路  3Comments

mattdharmon picture mattdharmon  路  3Comments