From f13144ceb89e24b31e33c9ee91370d9387c72d16 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:20:26 -0700 Subject: [PATCH] Remove widget type passing --- src/pages/api/services/proxy.js | 7 ++++++- src/utils/proxy/api-helpers.js | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/api/services/proxy.js b/src/pages/api/services/proxy.js index 595a94545..b77c5dd55 100644 --- a/src/pages/api/services/proxy.js +++ b/src/pages/api/services/proxy.js @@ -3,12 +3,17 @@ import createLogger from "utils/logger"; import genericProxyHandler from "utils/proxy/handlers/generic"; import widgets from "widgets/widgets"; import calendarProxyHandler from "widgets/calendar/proxy"; +import getServiceWidget from "utils/config/service-helpers"; const logger = createLogger("servicesProxy"); export default async function handler(req, res) { try { - const { type } = req.query; + const { service, group } = req.query; + const serviceWidget = await getServiceWidget(group, service); + let type = serviceWidget?.type; + // calendar is an alias for ical + if (type === "calendar") type = "ical"; const widget = widgets[type]; if (!widget) { diff --git a/src/utils/proxy/api-helpers.js b/src/utils/proxy/api-helpers.js index dceea3c4f..8e0682dbc 100644 --- a/src/utils/proxy/api-helpers.js +++ b/src/utils/proxy/api-helpers.js @@ -10,7 +10,6 @@ export function formatApiCall(url, args) { export function getURLSearchParams(widget, endpoint) { const params = new URLSearchParams({ - type: widget.type, group: widget.service_group, service: widget.service_name, });