diff --git a/lib/music_brainz/api_impl.ex b/lib/music_brainz/api_impl.ex index 26e562fc..af0ee506 100644 --- a/lib/music_brainz/api_impl.ex +++ b/lib/music_brainz/api_impl.ex @@ -449,6 +449,11 @@ defmodule MusicBrainz.APIImpl do {:ok, response} when response.status == 200 -> {:ok, Jason.decode!(response.body)} + {:ok, response} when response.status in 301..308 -> + location = :proplists.get_value("location", response.headers) + Logger.debug("Following redirect to #{location}") + json_get(location) + other -> msg = "Failed to fetch data from #{url}, reason: #{inspect(other)}" Logger.error(msg)