From 4e6df10a3eb0e10c5eed3359bc722a613fd22ca3 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 27 Nov 2023 10:09:43 +0100 Subject: [PATCH] Include Basic Auth in catalog request --- app/nuxt.config.ts | 1 + app/pages/index.vue | 19 ++++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/nuxt.config.ts b/app/nuxt.config.ts index 4d0b2b7bc..b063503b0 100644 --- a/app/nuxt.config.ts +++ b/app/nuxt.config.ts @@ -7,6 +7,7 @@ export default defineNuxtConfig({ public: { stacRoot: process.env.NUXT_STAC_ROOT, mapboxToken: process.env.NUXT_PUBLIC_MAPBOX_TOKEN, + password: process.env.NUXT_PUBLIC_PASSWORD, }, }, css: ['vuetify/styles'], diff --git a/app/pages/index.vue b/app/pages/index.vue index 0103ea9e6..ba3155f23 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -13,28 +13,21 @@ type CollectionType = typeof collectionShape let url = useRequestURL() let { - public: { mapboxToken }, + public: { mapboxToken, password }, } = useRuntimeConfig() let baseURL = url.protocol + '//' + url.host + '/stac' -console.log({ baseURL }) - let catalogPath = `${baseURL}/catalog.json` -let { data: catalogJson } = await useAsyncData(() => - fetch(catalogPath) - .then((res) => res.json()) - .catch((err) => { - console.error(err) - return null - }), -) +let { data: catalogJson } = await useFetch(catalogPath, { + headers: { + Authorization: `Basic ${btoa(password)}`, + }, +}) let catalog = catalogJson.value -console.log({ catalog }) - let childrenLinks = catalog?.links.filter((link) => link.rel === 'child') ?? [] let collections = (