Comments
0 min
Using Small API Proxies to Protect Frontend Keys
When a tiny backend service is cleaner than exposing service credentials in a browser app.
If a provider key should not be public, the browser should not receive it. A small API proxy can keep credentials server-side while giving the frontend a narrow endpoint to call.
js
app.get("/api/rates", async (req, res) => {
const response = await fetch(`${providerUrl}?key=${process.env.API_KEY}`);
res.json(await response.json());
});Keep the proxy narrow
Do not mirror the whole third-party API unless the app needs it. A focused endpoint is easier to cache, validate, rate-limit, and monitor.
Comments
Comments are not configured yet.