Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Jan 14, 2025
1 parent 4af6f9c commit b63ed35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/components/Bars/BarTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ const TopBar = () => {
}
useEffect(() => {
const fetchConfig = async () => {
const res = await fetch('/frontend_config.json')
const res = await fetch(
window?.location?.href?.split('#')[0] + 'frontend_config.json'
)
const configData = await res.json()
setFrConfig(configData)
}
Expand Down
26 changes: 17 additions & 9 deletions src/utils/Websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ interface WebSockette extends Sockette {
ws: WebSocket
}

let YZFLAG = false
// eslint-disable-next-line no-var
var YZFLAG = false
const YZFLAG2 = false

function createSocket() {
const host =
Expand All @@ -29,13 +31,15 @@ function createSocket() {
host.replace('https://', 'wss://').replace('http://', 'ws://') +
'/api/websocket'

if (YZFLAG) {
if (YZFLAG2) {
return 'mixedContent'
}
if (window.location.protocol === 'https:' && wsUrl.startsWith('ws://')) {
console.warn(
'Mixed content error: Cannot connect to ws:// from an https:// page.'
)
if (
window.location.protocol === 'https:' &&
wsUrl.startsWith('ws://') &&
YZFLAG
) {
console.info('BOOOM')
// return undefined
}

Expand Down Expand Up @@ -157,13 +161,17 @@ function createSocket() {
)
},
onerror: (e) => {
console.log('OMG Error:', e)
console.log(e)
YZFLAG = true
}
}) as WebSockette
return _ws
} catch (error) {
console.log('EYYYYYYY', error)
} catch (error: any) {
if (error.name === 'SecurityError') {
console.info('YOOO', JSON.stringify(error))
} else {
console.error('NOOO', JSON.stringify(error))
}
}
}

Expand Down

0 comments on commit b63ed35

Please sign in to comment.