Removed getDomain func.

This commit is contained in:
Dennis Postma 2025-02-09 03:34:33 +01:00
parent fcf96a25ae
commit c21e78c2ec
5 changed files with 5 additions and 23 deletions

View File

@ -1,4 +1,5 @@
VITE_NAME=Noxious
VITE_DOMAIN=localhost
VITE_ENVIRONMENT=development
VITE_SERVER_ENDPOINT=http://localhost:4000
VITE_TILE_SIZE_WIDTH=64

View File

@ -1,5 +1,6 @@
export default {
name: import.meta.env.VITE_NAME,
domain: import.meta.env.VITE_DOMAIN,
environment: import.meta.env.VITE_ENVIRONMENT,
server_endpoint: import.meta.env.VITE_SERVER_ENDPOINT,
tile_size: {

View File

@ -10,24 +10,6 @@ export function unduplicateArray(array: any[]) {
return [...new Set(array.flat())]
}
export function getDomain() {
// Check if not localhost
if (window.location.hostname !== 'localhost') {
return window.location.hostname
}
// Check if not IP address
if (window.location.hostname.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) {
return window.location.hostname
}
if (window.location.hostname.split('.').length < 3) {
return window.location.hostname
}
return window.location.hostname.split('.').slice(-2).join('.')
}
export async function downloadCache<T extends { id: string; updatedAt: Date }>(endpoint: string, storage: BaseStorage<T>) {
const request = await fetch(`${config.server_endpoint}/cache/${endpoint}`)
const response = (await request.json()) as HttpResponse<T[]>

View File

@ -1,5 +1,4 @@
import config from '@/application/config'
import { getDomain } from '@/application/utilities'
import { useCookies } from '@vueuse/integrations/useCookies'
import axios from 'axios'
@ -22,7 +21,7 @@ export async function login(username: string, password: string) {
try {
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
useCookies().set('token', response.data.data.token as string, {
domain: getDomain()
domain: config.domain
})
return { success: true, token: response.data.data.token }
} catch (error: any) {

View File

@ -1,6 +1,5 @@
import config from '@/application/config'
import type { Character, Notification, TextureData, User, WorldSettings } from '@/application/types'
import { getDomain } from '@/application/utilities'
import type { Character, Notification, User, WorldSettings } from '@/application/types'
import { useCookies } from '@vueuse/integrations/useCookies'
import { defineStore } from 'pinia'
import { io, Socket } from 'socket.io-client'
@ -102,7 +101,7 @@ export const useGameStore = defineStore('game', {
this.connection?.disconnect()
useCookies().remove('token', {
domain: getDomain()
domain: config.domain
})
this.connection = null