DenisCarriere / geocoder-geojson

Geocoding results in GeoJSON format
https://www.npmjs.com/package/geocoder-geojson
MIT License
21 stars 10 forks source link

Cannot set default Authorization header in my App without messing geocoder's axios #9

Closed terry90 closed 7 years ago

terry90 commented 7 years ago

When setting: axios.defaults.headers['Authorization'] in my app,

Google maps api will refuse the preflight request: Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

I changed my code to set the header in the post/get method and not in defaults.

I think it should be wise to create an instance of axios with no headers to reset the global config with the geocoder. like instance = axios.create(); instance.defaults.headers = {}; instance.get....

DenisCarriere commented 7 years ago

@terry90 Test this against the latest npm version, it should be fixed now.

Close the issue after or post what is happening.

terry90 commented 7 years ago

You are incredibly reactive ! Thank you, I will close if fixed 👍

terry90 commented 7 years ago

Woops, seems like headers.common is not set. Cannot read property 'Authorization' of undefined

DenisCarriere commented 7 years ago

@terry90 last commit should fix that undefined issue.

terry90 commented 7 years ago

Works like a charm