Option #2
Only if you absolutely must. But if you’re going with nodejs and koa-shopify-auth, it’s all handled for you and proper encoded host will be made available upon completion of the client auth process.
const params = new URLSearchParams(window.location.search);
const query = {
host: params.get("host"),
shop: params.get("shop")
};
// base64 encode "shop/admin" if query.host is absent
let host = query.host || btoa(`${query.shop}/admin`);
const provider = ;