Removed getDomain func.
This commit is contained in:
parent
fcf96a25ae
commit
c21e78c2ec
@ -1,4 +1,5 @@
|
|||||||
VITE_NAME=Noxious
|
VITE_NAME=Noxious
|
||||||
|
VITE_DOMAIN=localhost
|
||||||
VITE_ENVIRONMENT=development
|
VITE_ENVIRONMENT=development
|
||||||
VITE_SERVER_ENDPOINT=http://localhost:4000
|
VITE_SERVER_ENDPOINT=http://localhost:4000
|
||||||
VITE_TILE_SIZE_WIDTH=64
|
VITE_TILE_SIZE_WIDTH=64
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
name: import.meta.env.VITE_NAME,
|
name: import.meta.env.VITE_NAME,
|
||||||
|
domain: import.meta.env.VITE_DOMAIN,
|
||||||
environment: import.meta.env.VITE_ENVIRONMENT,
|
environment: import.meta.env.VITE_ENVIRONMENT,
|
||||||
server_endpoint: import.meta.env.VITE_SERVER_ENDPOINT,
|
server_endpoint: import.meta.env.VITE_SERVER_ENDPOINT,
|
||||||
tile_size: {
|
tile_size: {
|
||||||
|
@ -10,24 +10,6 @@ export function unduplicateArray(array: any[]) {
|
|||||||
return [...new Set(array.flat())]
|
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>) {
|
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 request = await fetch(`${config.server_endpoint}/cache/${endpoint}`)
|
||||||
const response = (await request.json()) as HttpResponse<T[]>
|
const response = (await request.json()) as HttpResponse<T[]>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import config from '@/application/config'
|
import config from '@/application/config'
|
||||||
import { getDomain } from '@/application/utilities'
|
|
||||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ export async function login(username: string, password: string) {
|
|||||||
try {
|
try {
|
||||||
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
|
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
|
||||||
useCookies().set('token', response.data.data.token as string, {
|
useCookies().set('token', response.data.data.token as string, {
|
||||||
domain: getDomain()
|
domain: config.domain
|
||||||
})
|
})
|
||||||
return { success: true, token: response.data.data.token }
|
return { success: true, token: response.data.data.token }
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import config from '@/application/config'
|
import config from '@/application/config'
|
||||||
import type { Character, Notification, TextureData, User, WorldSettings } from '@/application/types'
|
import type { Character, Notification, User, WorldSettings } from '@/application/types'
|
||||||
import { getDomain } from '@/application/utilities'
|
|
||||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { io, Socket } from 'socket.io-client'
|
import { io, Socket } from 'socket.io-client'
|
||||||
@ -102,7 +101,7 @@ export const useGameStore = defineStore('game', {
|
|||||||
this.connection?.disconnect()
|
this.connection?.disconnect()
|
||||||
|
|
||||||
useCookies().remove('token', {
|
useCookies().remove('token', {
|
||||||
domain: getDomain()
|
domain: config.domain
|
||||||
})
|
})
|
||||||
|
|
||||||
this.connection = null
|
this.connection = null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user