简体   繁体   中英

Angular http GET request No 'Access-Control-Allow-Origin' header

I'm currently building an application using Angular and Firebase (Firestore).

How can I retrieve the data located here http://maps.huge.info/zipv0.pl?ZIP=32750 and convert it from xml to json? This is my current get request but it's returning "No 'Access-Control-Allow-Origin' header is present on the requested resource". What am I doing wrong?

getZipData() {
  return this.http.get(`http://maps.huge.info/zipv0.pl?ZIP=19382`);
}

In your firebase config you can specify the following, found in the config options and that should resolve your issue.

"headers": [ { "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)", "headers" : [ { "key" : "Access-Control-Allow-Origin", "value" : "*" } ] }]

If you're using the angular-cli and running locally you can use the proxy config and proxy the URL while developing. https://juristr.com/blog/2016/11/configure-proxy-api-angular-cli/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM