Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
Vitaly Turovsky
e51e0e926a so damn clean cursor impl 2025-03-14 04:58:21 +03:00
Vitaly Turovsky
1ee52f7faa Merge branch 'next' into pr/zardoy/309 2025-03-14 04:58:13 +03:00
Vitaly Turovsky
a7bf484880 use proxy to download server resourece pack on any server from any not supporting cors url 2024-12-20 23:18:53 +03:00

View file

@ -389,11 +389,26 @@ const downloadAndUseResourcePack = async (url: string, progressReporter: Progres
progressReporter.beginStage('download-resource-pack', 'Downloading server resource pack')
console.log('Downloading server resource pack', url)
console.time('downloadServerResourcePack')
const response = await fetch(url).catch((err) => {
// Try direct URL first
let response = await fetch(url).catch((err) => {
console.log(`Ensure server on ${url} support CORS which is not required for regular client, but is required for the web client`)
console.error(err)
progressReporter.error('Failed to download resource pack: ' + err.message)
return null
})
// If direct URL fails, try proxy URL
if (!response) {
const urlWithoutProtocol = url.replace(/^https?:\/\//, '')
const proxyUrl = `https://mcraft-proxy.vercel.app/0/${urlWithoutProtocol}`
console.log('Trying fallback proxy URL:', proxyUrl)
response = await fetch(proxyUrl).catch((err) => {
console.error('Proxy fetch also failed:', err)
progressReporter.error('Failed to download resource pack: ' + err.message)
return null
})
}
console.timeEnd('downloadServerResourcePack')
if (!response) return