I'm playing around with Angular, trying to create a weather forecast app. I'm using the National Weather Service API
for data. There are 3 steps to retrieving a forecast:
1. get your latitude and longitude (the NWS doesn't offer geocoding, so we have to use a different api for this)
2. request the metadata ("points") for this location
3. using the points, request the forecast document.
Since this data resides on a server other than the one I'm working on, I need to proxy requests to the data servers. I set up the proxy.conf.json like so:
Now, in my angular code, I make a request to the US Census Geocoder API
The proxy rewrites this request and I get the latitude and longitude back. The output from the proxy looks like:
Next, in my angular code, I perform the second step, taking the latitude and longitude and requesting the points from the NWS. The URL I use looks like:
The output from the proxy is similar to the previous example, so it appears to do the correct thing rewriting the request:
However, I get a 404 error. The weird thing is, the URL reported for the error isn't the one I requested nor is it the rewritten one.
It's as if the proxy is trying to request the rewritten URL from localhost.
For another data point, I have another app in which I was working with another NWS API which basically goes by county (the API calls "zones"). Occasionally I will get failures when the service is overwhelmed. The URL in those errors will be what I expect, the unrewritten URL with localhost:
Now, the API that uses zones doesn't require geocoding, so the app proxy config only has one entry for the https://api.weather.gov
target. This leads me to believe that I have configured the proxy incorrectly. Is this the case or is there something else wrong?