Spaces:
Runtime error
Runtime error
Download proxy.js from sm6342/Yourmemory: direct link, hf CLI and curl.
- Browser
- Download file 746 Bytes
-
https://huggingface.co/spaces/sm6342/Yourmemory/resolve/main/proxy.js
- Command line
-
hf download hf://spaces/sm6342/Yourmemory/proxy.js
-
curl -L -o proxy.js https://huggingface.co/spaces/sm6342/Yourmemory/resolve/main/proxy.js
746 Bytes
| const http = require('http'); | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const { createProxyServer } = require('http-proxy'); | |
| const GATEWAY_PORT = 3100; | |
| const PORT = 8000; | |
| const proxy = createProxyServer({ target: `http://localhost:${GATEWAY_PORT}`, ws: true }); | |
| const serverCard = fs.readFileSync(path.join(__dirname, 'server-card.json')); | |
| const server = http.createServer((req, res) => { | |
| if (req.url === '/.well-known/mcp/server-card.json') { | |
| res.writeHead(200, { 'Content-Type': 'application/json' }); | |
| return res.end(serverCard); | |
| } | |
| proxy.web(req, res); | |
| }); | |
| server.on('upgrade', (req, socket, head) => { | |
| proxy.ws(req, socket, head); | |
| }); | |
| server.listen(PORT, () => console.log(`Proxy running on port ${PORT}`)); | |