nuxt / http

Universal HTTP Module for Nuxt.js
https://http.nuxtjs.org
MIT License
229 stars 51 forks source link

fix: correctly handle `proxyHeaders: false` #17

Closed perljusback closed 5 years ago

perljusback commented 5 years ago

When proxyHeaders is false trying to overwrite the object fails, added a conditional check on build to see if it exists or not.

perljusback commented 5 years ago

Good evening,

First great initiative i've been wanting to remove axios in favor for fetch for awhile now and this finaly got me to do it.

I noticed this error yesterday and figured i'd try and help with what i can.

Best Regards Per Anders Ljusbäck

pi0 commented 5 years ago

Hi @perljusback why did you closed the PR?

pi0 commented 5 years ago

I think defaults.headers is missing here: https://github.com/nuxt/http/blob/dev/lib/plugin.js#L97

perljusback commented 5 years ago

Sorry easter break... I'll resubmit if you want it.

The reason I moved it to a seperate condition in the build for process.server instead of adding it directly to the defaults object was to not set it twice, if the proxyHeader is present.

pi0 commented 5 years ago

This causes duplicate code. I suggest just adding default (empty object) for headers

perljusback commented 5 years ago

Ok updated, thanks for the input

pi0 commented 5 years ago

Thanks. Fixed in 0.1.1.