File size: 2,501 Bytes
5950c05 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
class ProxyWarning extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.warning {
background: rgba(234, 179, 8, 0.1);
border: 1px solid rgba(234, 179, 8, 0.2);
border-radius: 0.75rem;
padding: 1rem;
margin: 1rem 0;
color: rgba(234, 179, 8, 0.9);
}
.title {
font-weight: 600;
margin-bottom: 0.5rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.code {
background: rgba(0, 0, 0, 0.3);
padding: 0.75rem;
border-radius: 0.5rem;
font-family: monospace;
font-size: 0.8rem;
margin-top: 0.5rem;
overflow-x: auto;
}
</style>
<div class="warning">
<div class="title">
<i data-feather="alert-triangle"></i>
Proxy Recommendation
</div>
<div class="text-sm">
For reliable connections, run this local proxy server:
</div>
<div class="code">
npm install express node-fetch<br>
// Create server.js with:<br>
const express = require('express');<br>
const fetch = require('node-fetch');<br><br>
const app = express();<br>
app.use(express.json());<br><br>
app.post("/api/rosalinda", async (req, res) => {<br>
try {<br>
const response = await fetch("API_URL", {<br>
method: "POST",<br>
headers: {<br>
"Content-Type": "application/json",<br>
"Authorization": "Bearer YOUR_API_KEY"<br>
},<br>
body: JSON.stringify(req.body)<br>
});<br>
res.json(await response.json());<br>
} catch (err) {<br>
res.status(500).json({ error: err.message });<br>
}<br>
});<br><br>
app.listen(3000, () => console.log("Proxy running"));
</div>
</div>
`;
feather.replace();
}
}
customElements.define('proxy-warning', ProxyWarning); |