mirror of
https://codeberg.org/SafeTwitch/safetwitch.git
synced 2025-01-03 03:10:04 -05:00
Fix protocol issues
This commit is contained in:
parent
c3fd5cd56d
commit
dcb6258a45
8 changed files with 28 additions and 22 deletions
|
@ -3,7 +3,7 @@ import { RouterView } from 'vue-router'
|
||||||
import NavbarItem from './components/NavbarView.vue'
|
import NavbarItem from './components/NavbarView.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template class="bg-ctp-base">
|
||||||
<navbar-item></navbar-item>
|
<navbar-item></navbar-item>
|
||||||
|
|
||||||
<Suspense>
|
<Suspense>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { inject } from 'vue'
|
||||||
export interface Stream {
|
export interface Stream {
|
||||||
tags: string[]
|
tags: string[]
|
||||||
title: string
|
title: string
|
||||||
|
@ -20,7 +21,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async setup(props) {
|
async setup(props) {
|
||||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
const protocol = inject('protocol')
|
||||||
|
|
||||||
let streamData: Stream | null = null
|
let streamData: Stream | null = null
|
||||||
if (!props.stream && props.name) {
|
if (!props.stream && props.name) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref, type Ref } from 'vue'
|
import { ref, type Ref, inject } from 'vue'
|
||||||
import BadgeVue from './ChatBadge.vue'
|
import BadgeVue from './ChatBadge.vue'
|
||||||
import { getBadges } from '@/assets/badges'
|
import { getBadges } from '@/assets/badges'
|
||||||
import { parseMessage } from '@/assets/messageParser'
|
import { parseMessage } from '@/assets/messageParser'
|
||||||
|
@ -19,13 +19,13 @@ export default {
|
||||||
},
|
},
|
||||||
async setup(props) {
|
async setup(props) {
|
||||||
let messages: Ref<ParsedMessage[]> = ref([])
|
let messages: Ref<ParsedMessage[]> = ref([])
|
||||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
const protocol = inject('protocol')
|
||||||
|
const wsProtocol = protocol === 'https://' ? 'wss://' : 'ws://'
|
||||||
const badgesFetch = await fetch(`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/badges?channelName=${props.channelName}`)
|
const badgesFetch = await fetch(`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/badges?channelName=${props.channelName}`)
|
||||||
let badges: Badge[] = (await badgesFetch.json()).data
|
let badges: Badge[] = (await badgesFetch.json()).data
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ws: new WebSocket(`ws://${import.meta.env.VITE_BACKEND_DOMAIN}`),
|
ws: new WebSocket(`${wsProtocol}://${import.meta.env.VITE_BACKEND_DOMAIN}`),
|
||||||
messages,
|
messages,
|
||||||
badges,
|
badges,
|
||||||
props,
|
props,
|
||||||
|
|
11
src/main.ts
11
src/main.ts
|
@ -5,6 +5,15 @@ import './assets/index.css'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
|
// Add protocol variable
|
||||||
|
// For some reason, import.meta.env.VITE_HTTPS === "true"
|
||||||
|
// returns false, even if it is true.
|
||||||
|
// Making a copy of the variable seems to work
|
||||||
|
const https = (import.meta.env.VITE_HTTPS.slice() === "true")
|
||||||
|
app.provide('protocol', https ? 'https://' : 'http://')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { OhVueIcon, addIcons } from 'oh-vue-icons'
|
import { OhVueIcon, addIcons } from 'oh-vue-icons'
|
||||||
import {
|
import {
|
||||||
IoSearchOutline,
|
IoSearchOutline,
|
||||||
|
@ -34,4 +43,4 @@ addIcons(
|
||||||
|
|
||||||
app.component('v-icon', OhVueIcon)
|
app.component('v-icon', OhVueIcon)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
|
@ -6,17 +6,14 @@ import ErrorMessage from '@/components/ErrorMessage.vue'
|
||||||
import LoadingScreen from '@/components/LoadingScreen.vue'
|
import LoadingScreen from '@/components/LoadingScreen.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
inject: ['protocol'],
|
||||||
async setup() {
|
async setup() {
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
|
||||||
const data: Ref<any | undefined> = ref()
|
const data: Ref<any | undefined> = ref()
|
||||||
const frontend_url = protocol + import.meta.env.VITE_INSTANCE_DOMAIN
|
|
||||||
const game: string = route.params.game.toString()
|
const game: string = route.params.game.toString()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
frontend_url,
|
|
||||||
protocol,
|
|
||||||
game
|
game
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,16 +6,12 @@ import LoadingScreen from '@/components/LoadingScreen.vue'
|
||||||
import CategoryPreview from '@/components/CategoryPreview.vue'
|
import CategoryPreview from '@/components/CategoryPreview.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
inject: ['protocol'],
|
||||||
async setup() {
|
async setup() {
|
||||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
|
||||||
|
|
||||||
let data: Ref<any | undefined> = ref()
|
let data: Ref<any | undefined> = ref()
|
||||||
let frontend_url = protocol + import.meta.env.VITE_INSTANCE_DOMAIN
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
protocol,
|
|
||||||
frontend_url,
|
|
||||||
filterTags: '',
|
filterTags: '',
|
||||||
following: ref([])
|
following: ref([])
|
||||||
}
|
}
|
||||||
|
@ -82,6 +78,10 @@ export default {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${this.protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/discover`)
|
const res = await fetch(`${this.protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/discover`)
|
||||||
|
|
||||||
|
console.log(this.protocol, this)
|
||||||
|
console.log(import.meta.env)
|
||||||
|
|
||||||
const rawData = await res.json()
|
const rawData = await res.json()
|
||||||
if (rawData.status === 'ok') {
|
if (rawData.status === 'ok') {
|
||||||
this.data = rawData.data
|
this.data = rawData.data
|
||||||
|
|
|
@ -7,6 +7,7 @@ import StreamPreviewVue from '@/components/StreamPreview.vue'
|
||||||
import ChannelPreview from '@/components/ChannelPreview.vue'
|
import ChannelPreview from '@/components/ChannelPreview.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
inject: ['protocol'],
|
||||||
setup() {
|
setup() {
|
||||||
let data: Ref<any> = ref(null)
|
let data: Ref<any> = ref(null)
|
||||||
return {
|
return {
|
||||||
|
@ -15,8 +16,7 @@ export default {
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
try {
|
try {
|
||||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
const res = await fetch(`${this.protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/search?query=${this.$route.query.query}`)
|
||||||
const res = await fetch(`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/search?query=${this.$route.query.query}`)
|
|
||||||
const rawData = await res.json()
|
const rawData = await res.json()
|
||||||
|
|
||||||
this.data = rawData.data
|
this.data = rawData.data
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref, inject } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import VideoPlayer from '@/components/VideoPlayer.vue'
|
import VideoPlayer from '@/components/VideoPlayer.vue'
|
||||||
import TwitchChat from '@/components/TwitchChat.vue'
|
import TwitchChat from '@/components/TwitchChat.vue'
|
||||||
|
@ -11,8 +11,8 @@ export default {
|
||||||
async setup() {
|
async setup() {
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const username = route.params.username
|
const username = route.params.username
|
||||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
|
||||||
const data = ref()
|
const data = ref()
|
||||||
|
const protocol = inject('protocol')
|
||||||
const videoOptions = {
|
const videoOptions = {
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
controls: true,
|
controls: true,
|
||||||
|
@ -42,11 +42,10 @@ export default {
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
const username = this.$route.params.username
|
const username = this.$route.params.username
|
||||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/users/${username}`
|
`${this.protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/users/${username}`
|
||||||
)
|
)
|
||||||
const rawData = await res.json()
|
const rawData = await res.json()
|
||||||
if (rawData.status === 'ok') {
|
if (rawData.status === 'ok') {
|
||||||
|
|
Loading…
Reference in a new issue