Spaces:
Sleeping
Sleeping
Commit ·
ff8acbc
1
Parent(s): 083e88b
Add Cloudflare Worker proxy for memisislabs.ai
Browse files- cloudflare-worker.js +17 -0
cloudflare-worker.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// MemisisLabs — Cloudflare Worker proxy: memisislabs.ai -> HF Space
|
| 2 |
+
// Free, no HF PRO. Keeps memisislabs.ai in the address bar and proxies
|
| 3 |
+
// Streamlit's HTTP + WebSocket traffic to the Space.
|
| 4 |
+
|
| 5 |
+
const ORIGIN = "nnagesh101-memisislabs.hf.space";
|
| 6 |
+
|
| 7 |
+
export default {
|
| 8 |
+
async fetch(request) {
|
| 9 |
+
const url = new URL(request.url);
|
| 10 |
+
url.hostname = ORIGIN; // route to the HF Space (sets Host: <origin> too)
|
| 11 |
+
url.protocol = "https:";
|
| 12 |
+
url.port = "";
|
| 13 |
+
// Pass the request through unchanged (preserves the WebSocket Upgrade header
|
| 14 |
+
// for Streamlit's /_stcore/stream). Cloudflare proxies the 101 response.
|
| 15 |
+
return fetch(new Request(url.toString(), request));
|
| 16 |
+
},
|
| 17 |
+
};
|