From a3b21edf0c1250accd2860a01561e7d725e1ed1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Tue, 5 Apr 2022 12:43:21 +0200 Subject: [PATCH] Metadata improvements --- packages/dashboard-v2/src/lib/swrConfig.js | 9 +++------ packages/dashboard-v2/src/services/skynetClient.js | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/dashboard-v2/src/lib/swrConfig.js b/packages/dashboard-v2/src/lib/swrConfig.js index 16e2dbfb..b4954fc9 100644 --- a/packages/dashboard-v2/src/lib/swrConfig.js +++ b/packages/dashboard-v2/src/lib/swrConfig.js @@ -1,11 +1,8 @@ import { navigate } from "gatsby"; import { StatusCodes } from "http-status-codes"; -// TODO: portal-aware URL -const baseUrl = process.env.NODE_ENV !== "production" ? "/api" : "https://account.skynetpro.net/api"; - const redirectUnauthenticated = (key) => - fetch(`${baseUrl}/${key}`).then((response) => { + fetch(`/api/${key}`).then((response) => { if (response.status === StatusCodes.UNAUTHORIZED) { navigate(`/auth/login?return_to=${encodeURIComponent(window.location.href)}`); return null; @@ -15,7 +12,7 @@ const redirectUnauthenticated = (key) => }); const redirectAuthenticated = (key) => - fetch(`${baseUrl}/${key}`).then(async (response) => { + fetch(`/api/${key}`).then(async (response) => { if (response.ok) { await navigate("/"); return response.json(); @@ -27,7 +24,7 @@ const redirectAuthenticated = (key) => }); export const allUsers = { - fetcher: (key) => fetch(`${baseUrl}/${key}`).then((response) => response.json()), + fetcher: (key) => fetch(`/api/${key}`).then((response) => response.json()), }; export const authenticatedOnly = { diff --git a/packages/dashboard-v2/src/services/skynetClient.js b/packages/dashboard-v2/src/services/skynetClient.js index 0549085c..a01e96f9 100644 --- a/packages/dashboard-v2/src/services/skynetClient.js +++ b/packages/dashboard-v2/src/services/skynetClient.js @@ -1,3 +1,3 @@ import { SkynetClient } from "skynet-js"; -export default new SkynetClient("https://skynetpro.net"); // TODO: proper API url +export default new SkynetClient(`https://${process.env.GATSBY_PORTAL_DOMAIN}`);