refactor: make sure that port '80' and '443' are correctly passed through (#631)
This commit is contained in:
1 parent
0cf8ba05be
commit
fd22cc297d
1 file changed
+24
-6
@@ -3,19 +3,37 @@ import { SocketState } from '@/store/socket/types'
|
||||
import { actions } from '@/store/socket/actions'
|
||||
import { mutations } from '@/store/socket/mutations'
|
||||
import { getters } from '@/store/socket/getters'
|
||||
import {RootState} from '@/store/types'
|
||||
import { RootState } from '@/store/types'
|
||||
|
||||
export const getDefaultState = (): SocketState => {
|
||||
let remoteMode: boolean
|
||||
let hostname: string
|
||||
let port: number
|
||||
|
||||
if (
|
||||
document.location.hostname === 'my.mainsail.xyz' ||
|
||||
import.meta.env.VUE_APP_REMOTE_MODE
|
||||
) {
|
||||
remoteMode = true
|
||||
hostname = ''
|
||||
port = 7125
|
||||
} else {
|
||||
remoteMode = false
|
||||
hostname = import.meta.env.VUE_APP_HOSTNAME as string || window.location.hostname
|
||||
const defaultPort = window.location.port || (window.location.protocol === 'https:' ? 443 : 80)
|
||||
port = import.meta.env.VUE_APP_PORT ? Number(import.meta.env.VUE_APP_PORT) : Number(defaultPort)
|
||||
}
|
||||
|
||||
return {
|
||||
remoteMode: import.meta.env.VUE_APP_REMOTE_MODE === true || (document.location.hostname === 'my.mainsail.xyz'),
|
||||
hostname: (import.meta.env.VUE_APP_HOSTNAME as string) || ((import.meta.env.VUE_APP_REMOTE_MODE === true || document.location.hostname === 'my.mainsail.xyz') ? '' : window.location.hostname),
|
||||
port: Number(import.meta.env.VUE_APP_PORT || (import.meta.env.VUE_APP_REMOTE_MODE === true || document.location.hostname === 'my.mainsail.xyz' ? 7125 : window.location.port)),
|
||||
remoteMode,
|
||||
hostname,
|
||||
port,
|
||||
protocol: document.location.protocol === 'https:' ? 'wss' : 'ws',
|
||||
reconnectInterval: Number(import.meta.env.VUE_APP_RECONNECT_INTERVAL || 2000),
|
||||
isConnected: false,
|
||||
isConnecting: false,
|
||||
connectingFailed: false,
|
||||
loadings: []
|
||||
loadings: [],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +45,5 @@ export const socket: Module<SocketState, RootState> = {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
mutations,
|
||||
}
|
||||
Reference in new issue
Block a user