Examples
Next.js:
js
// https://nextjs.org/docs/pages/api-reference/next-config-js/rewrites
module.exports = {
async rewrites() {
return [
{
source: "/elevar", // your proxy path
destination: "https://hits.getelevar.com" // our server URL
}
];
}
};Remix / Hydrogen:
js
// https://remix.run/docs/en/main/guides/resource-routes
// Your proxy path is based on the path of this file.
// For example, this file's proxy path would be "/elevar".
// If using a different path, update `outPath` below.
const outOrigin = "https://hits.getelevar.com";
const proxy = async ({ request }) => {
const inUrl = new URL(request.url);
const outPath = inUrl.pathname.replace("/elevar", "");
const outUrl = new URL(outPath + inUrl.search, outOrigin);
const newRequest = new Request(outUrl.toString(), new Request(request));
return await fetch(newRequest);
};
export const loader = proxy;
export const action = proxy;Nuxt:
ts
// https://nuxt.com/docs/api/nuxt-config#nitro
// https://nitro.unjs.io/config#routerules
export default defineNuxtConfig({
nitro: {
routeRules: {
// your proxy path
"/elevar": {
// our server URL
proxy: "https://hits.getelevar.com"
}
}
}
});Express:
js
// https://expressjs.com/
// https://github.com/villadora/express-http-proxy
app.use(
"/elevar", // your proxy path
proxy("https://hits.getelevar.com") // our server URL
);Elevar's Script:
html
<script type="module">
try {
const settings = { proxyPath: "/elevar" }; // your proxy path
//update to include proxy path
const config = (await import("/elevar/static/configs/.../config.js"))
.default;
const scriptUrl = settings.proxyPath
? `${settings.proxyPath}${config.script_src_custom_pages_proxied}`
: config.script_src_custom_pages;
if (scriptUrl) {
const { handler } = await import(scriptUrl);
await handler(config, settings);
}
} catch (error) {
console.error("Elevar Error:", error);
}
</script>