chore: updated cors proxy
dc5c207e
1 file(s) · +47 −15
| 75 | 75 | const response = await fetch(url); |
|
| 76 | 76 | return await response.text(); |
|
| 77 | 77 | } catch { |
|
| 78 | - | // Fall back to CORS proxy if direct fetch fails |
|
| 79 | - | const response = await fetch( |
|
| 80 | - | `https://corsproxy.io/?url=${encodeURIComponent(url)}`, |
|
| 81 | - | ); |
|
| 82 | - | return await response.text(); |
|
| 78 | + | // Fall back to primary CORS proxy if direct fetch fails |
|
| 79 | + | try { |
|
| 80 | + | const response = await fetch( |
|
| 81 | + | `https://proxy.alcove.tools?url=${encodeURIComponent(url)}`, |
|
| 82 | + | ); |
|
| 83 | + | return await response.text(); |
|
| 84 | + | } catch { |
|
| 85 | + | // Fall back to secondary CORS proxy if primary fails |
|
| 86 | + | const response = await fetch( |
|
| 87 | + | `https://proxy2.alcove.tools?url=${encodeURIComponent(url)}`, |
|
| 88 | + | ); |
|
| 89 | + | return await response.text(); |
|
| 90 | + | } |
|
| 83 | 91 | } |
|
| 84 | 92 | } |
|
| 85 | 93 | ||
| 152 | 160 | const testUrl = `${origin}${path}`; |
|
| 153 | 161 | ||
| 154 | 162 | try { |
|
| 155 | - | // Use CORS proxy to avoid CORS issues |
|
| 156 | - | const response = await fetch( |
|
| 157 | - | `https://corsproxy.io/?url=${encodeURIComponent(testUrl)}`, |
|
| 158 | - | ); |
|
| 163 | + | // Try primary CORS proxy |
|
| 164 | + | let response: Response; |
|
| 165 | + | try { |
|
| 166 | + | response = await fetch( |
|
| 167 | + | `https://proxy.alcove.tools?url=${encodeURIComponent(testUrl)}`, |
|
| 168 | + | ); |
|
| 169 | + | } catch { |
|
| 170 | + | // Fall back to secondary CORS proxy |
|
| 171 | + | response = await fetch( |
|
| 172 | + | `https://proxy2.alcove.tools?url=${encodeURIComponent(testUrl)}`, |
|
| 173 | + | ); |
|
| 174 | + | } |
|
| 159 | 175 | ||
| 160 | 176 | if (response.ok) { |
|
| 161 | 177 | const text = await response.text(); |
|
| 213 | 229 | ||
| 214 | 230 | // Fetch the YouTube page to extract the channel ID from meta tags |
|
| 215 | 231 | try { |
|
| 216 | - | const response = await fetch( |
|
| 217 | - | `https://corsproxy.io/?url=${encodeURIComponent(url)}`, |
|
| 218 | - | ); |
|
| 232 | + | let response: Response; |
|
| 233 | + | try { |
|
| 234 | + | response = await fetch( |
|
| 235 | + | `https://proxy.alcove.tools?url=${encodeURIComponent(url)}`, |
|
| 236 | + | ); |
|
| 237 | + | } catch { |
|
| 238 | + | // Fall back to secondary CORS proxy |
|
| 239 | + | response = await fetch( |
|
| 240 | + | `https://proxy2.alcove.tools?url=${encodeURIComponent(url)}`, |
|
| 241 | + | ); |
|
| 242 | + | } |
|
| 219 | 243 | const html = await response.text(); |
|
| 220 | 244 | ||
| 221 | 245 | // Look for channel ID in various places |
|
| 248 | 272 | // For /c/ and /user/ formats, we also need to fetch the page |
|
| 249 | 273 | if (url.includes("/c/") || url.includes("/user/")) { |
|
| 250 | 274 | try { |
|
| 251 | - | const response = await fetch( |
|
| 252 | - | `https://corsproxy.io/?url=${encodeURIComponent(url)}`, |
|
| 253 | - | ); |
|
| 275 | + | let response: Response; |
|
| 276 | + | try { |
|
| 277 | + | response = await fetch( |
|
| 278 | + | `https://proxy.alcove.tools?url=${encodeURIComponent(url)}`, |
|
| 279 | + | ); |
|
| 280 | + | } catch { |
|
| 281 | + | // Fall back to secondary CORS proxy |
|
| 282 | + | response = await fetch( |
|
| 283 | + | `https://proxy2.alcove.tools?url=${encodeURIComponent(url)}`, |
|
| 284 | + | ); |
|
| 285 | + | } |
|
| 254 | 286 | const html = await response.text(); |
|
| 255 | 287 | ||
| 256 | 288 | const channelIdMatch = html.match(/channelId":"([^"]+)"/); |
|