Skip to content

Commit

Permalink
Load pre-defined maps directly; move proxy to /api namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
kravets-levko committed Feb 11, 2020
1 parent 813d97a commit c7b1345
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions client/app/visualizations/choropleth/hooks/useLoadGeoJson.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { isString, isObject } from "lodash";
import { isString, isObject, find } from "lodash";
import { useState, useEffect } from "react";
import { axios } from "@/services/axios";
import createReferenceCountingCache from "@/lib/referenceCountingCache";
import maps from "../maps";

const cache = createReferenceCountingCache();

function withProxy(url) {
return `/resource-proxy?url=${encodeURIComponent(url)}`;
// if it's one of predefined maps - use it directly
if (find(maps, map => map.url === url)) {
return url;
}
return `/api/resource-proxy?url=${encodeURIComponent(url)}`;
}

export default function useLoadGeoJson(url) {
Expand Down
2 changes: 1 addition & 1 deletion redash/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def status_api():
return jsonify(status)


@routes.route("/resource-proxy", methods=["GET"])
@routes.route("/api/resource-proxy", methods=["GET"])
def resource_proxy():
response = requests.get(request.args.get('url'))
allow_headers = ['content-type']
Expand Down

0 comments on commit c7b1345

Please sign in to comment.