From 8ecb77e430614383be2499f08541c7987595c040 Mon Sep 17 00:00:00 2001 From: dragongoose Date: Sat, 8 Apr 2023 20:04:28 -0400 Subject: [PATCH] Use proper urls --- .env | 5 +++-- env.d.ts | 5 +++-- src/components/StreamPreview.vue | 13 +++++++------ src/components/TwitchChat.vue | 7 ++++--- src/views/CategoryView.vue | 6 ++++-- src/views/HomepageView.vue | 9 ++++++--- src/views/UserView.vue | 5 +++-- 7 files changed, 30 insertions(+), 20 deletions(-) diff --git a/.env b/.env index 694ad76..adeecea 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ -VITE_BACKEND_URL=http://localhost:7000 -VITE_INSTANCE_URL=http://localhost:5173 \ No newline at end of file +VITE_BACKEND_DOMAIN=localhost:7000 +VITE_INSTANCE_DOMAIN=localhost:5173 +VITE_HTTPS=false \ No newline at end of file diff --git a/env.d.ts b/env.d.ts index 5a8edb6..e9c774b 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,8 +1,9 @@ /// interface ImportMetaEnv { - readonly VITE_BACKEND_URL: string - readonly VITE_INSTANCE_URL: string + readonly VITE_BACKEND_DOMAIN: string + readonly VITE_INSTANCE_DOMAIN: string + readonly VITE_HTTPS: string // more env variables... } diff --git a/src/components/StreamPreview.vue b/src/components/StreamPreview.vue index 1395df3..6efdbe7 100644 --- a/src/components/StreamPreview.vue +++ b/src/components/StreamPreview.vue @@ -20,11 +20,12 @@ export default { } }, async setup(props) { + const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://' let streamData: Stream | null = null if (!props.stream && props.name) { const streamDataFetch = await fetch( - `${import.meta.env.VITE_BACKEND_URL}/api/users/${props.name}` + `${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/users/${props.name}` ) const data = await streamDataFetch.json() @@ -36,11 +37,12 @@ export default { streamData = props.stream as Stream } - const frontend_url = import.meta.env.VITE_INSTANCE_URL + const frontend_url = protocol + import.meta.env.VITE_INSTANCE_DOMAIN return { frontend_url, - streamData + streamData, + protocol } }, methods: { @@ -58,10 +60,9 @@ export default {