Browse Source

silence window-scope error

master^2
Silberengel 2 months ago
parent
commit
813a856e24
  1. 9
      src/lib/utils/network_detection.ts

9
src/lib/utils/network_detection.ts

@ -25,8 +25,9 @@ const NETWORK_ENDPOINTS = [
export async function isNetworkOnline(): Promise<boolean> { export async function isNetworkOnline(): Promise<boolean> {
for (const endpoint of NETWORK_ENDPOINTS) { for (const endpoint of NETWORK_ENDPOINTS) {
try { try {
// Use a simple fetch without HEAD method to avoid CORS issues // Use window.fetch explicitly for client-side network detection
await fetch(endpoint, { // This is intentionally client-side code, not a SvelteKit load function
await window.fetch(endpoint, {
method: "GET", method: "GET",
cache: "no-cache", cache: "no-cache",
signal: AbortSignal.timeout(3000), signal: AbortSignal.timeout(3000),
@ -56,7 +57,9 @@ export async function testNetworkSpeed(): Promise<number> {
for (const endpoint of NETWORK_ENDPOINTS) { for (const endpoint of NETWORK_ENDPOINTS) {
try { try {
await fetch(endpoint, { // Use window.fetch explicitly for client-side network detection
// This is intentionally client-side code, not a SvelteKit load function
await window.fetch(endpoint, {
method: "GET", method: "GET",
cache: "no-cache", cache: "no-cache",
signal: AbortSignal.timeout(5000), signal: AbortSignal.timeout(5000),

Loading…
Cancel
Save