add automatic localhost and local ip for allowOrigin

This commit is contained in:
Adrian Zuercher
2025-06-29 21:26:16 +02:00
parent c58dbf34d0
commit e320156a47
4 changed files with 48 additions and 6 deletions

View File

@@ -4,8 +4,8 @@ import { initWebSocket } from 'src/services/websocket';
export default boot(({ app }) => {
const $q = app.config.globalProperties.$q as QVueGlobals;
const host = window.location.hostname; // gets current domain or IP
const port = 8100; // your WebSocket port
const host = window.location.hostname;
const port = 8100;
const randomId = Math.floor(Math.random() * 10001); // random number from 0 to 10000
const ws = initWebSocket(`ws://${host}:${port}/ws?id=q${randomId}`, $q);

View File

@@ -133,9 +133,12 @@ const newScene = reactive<Scene>({
});
const scenes = ref<Scene[]>([]);
const host = window.location.hostname;
const port = 9500;
const baseURL = `http://${host}:${port}`;
const quasarApi = axios.create({
baseURL: `http://localhost:9500`,
baseURL: baseURL,
timeout: 10000,
headers: {
'Content-Type': 'application/json',
@@ -150,7 +153,9 @@ onMounted(() => {
scenes.value = resp.data;
}
})
.catch((err) => NotifyResponse($q, err.response.data.error, 'error'));
.catch((err) => {
NotifyResponse($q, err.response.data.error, 'error');
});
});
function removeScene(name: string) {