Spaces:
Running
Running
Improve CORS error handling
Browse filesAdd specific error message for CORS-related fetch failures to help users understand when cross-origin requests are blocked.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
- index.html +5 -1
index.html
CHANGED
@@ -42,7 +42,11 @@
|
|
42 |
</div>
|
43 |
`;
|
44 |
} catch (error) {
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
}
|
48 |
</script>
|
|
|
42 |
</div>
|
43 |
`;
|
44 |
} catch (error) {
|
45 |
+
let errorMessage = error.message;
|
46 |
+
if (error.message.includes('Failed to fetch') || error.name === 'TypeError') {
|
47 |
+
errorMessage = `CORS Error: ${error.message}. The server may not allow cross-origin requests from this domain.`;
|
48 |
+
}
|
49 |
+
responseDiv.innerHTML = `<div class="error">Error: ${errorMessage}</div>`;
|
50 |
}
|
51 |
}
|
52 |
</script>
|