Request headers: unable to override content type ?

begueradj
30
begueradj
commented 2 months ago

Version

v4.5.3

Reproduction link

https://auth.nuxtjs.org/

Steps to reproduce

DO the settings as show in the documentation and use a REST API.

What is expected ?

I want to override the header content type to post files

What is actually happening?

I can not post files because the default header content type is JSON ('content-type': 'application/json;charset=UTF-8',)

What I tried

  1. I tried to override the axios (as shown here) headers by editing nuxt.config.js to add the multipart content type,
  2. On my client function call, I run this.$axios.setHeader('content-type', 'multipart/form-data')

In both attempts, on the server side I still see my POST request having both the JSON and multipart content type .

Billal Begueradj

bug
0
begueradj
30
begueradj
commented 2 months ago

I fixed the issue the usual way: injecting the headers directly into the request itself.
But that is weird setHeaders does not work as I imagined it to work. Maybe I need to read more about it.

0
Informations
Bug Report โ€ข Open
#c300 - Created 2 months ago