My goal is to enable players to join a game using a QR Code. Since the game will be hosted on multiple IP addresses, I need to dynamically generate the URL.
Below is my current workaround in my NuxtJS Vue Component:
<template>
<input placeholder="copy browser window url into this field" v-model="fullPath" @change="generateQR">
</template>
<script setup>
const fullPath = ref(null)
QRCode.toDataURL(fullPath.value + ...
</script>
My desired approach would be something like this:
<script setup>
// pseudo code (not functional)
QRCode.toDataURL(window.location.href + ...
</script>
Even when using the useRouter() and useRoute()'s .fullPath
attribute, I am still only getting the relative path /
instead of http://10.16.1.173:3000/
.
View the full code on GitLab: pages/index.vue