Skip to content

Commit

Permalink
fix: use cors proxy when fetching fails
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed Dec 8, 2024
1 parent c0f3194 commit c643d43
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/playground/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ function App() {
}

async function loadFromURL(url: string) {
const response = await fetch(url).catch(() =>
fetch('https://corsproxy.io/?' + encodeURIComponent(url)),
);
let response = await fetch(url);
if (!response.ok) {
response = await fetch(
'https://corsproxy.io/?' + encodeURIComponent(url),
);
}
if (response.ok) {
const model = activeTab() || openUntitledTab();
model.setValue(await response.text());
Expand Down

0 comments on commit c643d43

Please sign in to comment.