Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed local FE dev server not working for the newest URL changes #266

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions frontend/src/components/MapView/DataFetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const geojsonGemeindenPolygons: FeatureCollection =

// These values will be replaced after build with the .sh script when spinning up docker container.
export const currentEnvironment = {
apiBaseHost: "API_GATEWAY_HOST",
apiBasePort: "API_GATEWAY_PORT",
apiGatewayHost: "API_GATEWAY_HOST",
apiGatewayPort: "API_GATEWAY_PORT",
};

const useGeoData = (
Expand All @@ -33,19 +33,28 @@ const useGeoData = (
(tab) => tab.dataset.id === id
);

// Returns the API URL of the endpoint for a specific dataset
const getApiUrlForDataset = (): string => {
// Returns the API Gateway URL for a specific deployment environment
// The .join() function ensures that this strings will not be replace by the .sh script.
const getAPIGatewayURL = (): string => {
return (
"http://" +
(currentEnvironment.apiGatewayHost === ["API_", "GATEWAY_", "HOST"].join()
? currentEnvironment.apiGatewayHost
: "localhost") +
":" +
(currentEnvironment.apiGatewayPort === ["API_", "GATEWAY_", "PORT"].join()
? currentEnvironment.apiGatewayPort
: "8081")
);
};

// Returns the API Gateway URL of the endpoint for a specific dataset.
const getViewportDatasetEndpoint = (): string => {
switch (id) {
case "empty_map":
return "";
default:
return (
"http://" +
currentEnvironment.apiBaseHost +
":" +
currentEnvironment.apiBasePort +
"/api/getDatasetViewportData"
);
return getAPIGatewayURL() + "/api/getDatasetViewportData";
}
};

Expand Down Expand Up @@ -82,9 +91,9 @@ const useGeoData = (
ZoomLevel: zoom,
datasetID: id,
};
console.log(getApiUrlForDataset());
console.log(getViewportDatasetEndpoint());
const response = await axios.get<FeatureCollection<Geometry>>(
getApiUrlForDataset(),
getViewportDatasetEndpoint(),
{
params,
}
Expand Down
Loading