A
A
Ayan Bai2016-05-16 17:05:25
Angular
Ayan Bai, 2016-05-16 17:05:25

How to use cors npm package?

I make a request to google through angular $http, it gives an error

XMLHttpRequest cannot load http://maps.googleapis.com/maps/api/geocode/json?address=%D0%94%D0%BE%D1%81&sensor=false. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

I found such a package cors , they write that it will help if you add the code app.use('cors());
. There is no effect.
What to do ? Why does not it work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-05-16
@wolf47


cors is a middleware for express, a library running on the server, and has nothing to do with angular (running on the client).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question