diff --git a/src/dpid-reader/DpidReader.ts b/src/dpid-reader/DpidReader.ts index 41566d8..e7cce3f 100644 --- a/src/dpid-reader/DpidReader.ts +++ b/src/dpid-reader/DpidReader.ts @@ -27,6 +27,7 @@ export interface DpidRequest { prefix: string; raw?: boolean; jsonld?: boolean; + domain?: string; } // export const encodeBase64UrlSafe = (bytes: Buffer) => { @@ -137,7 +138,7 @@ export class DpidReader { }; private static transformWeb = async (result: DpidResult, request: DpidRequest) => { - const { prefix, suffix, version } = request; + const { prefix, suffix, version, domain } = request; const uuid = result.id64; const output = { msg: `beta.dpid.org resolver`, params: request, uuid }; @@ -147,13 +148,9 @@ export class DpidReader { : version?.substring(0, 1) == "v" ? version : `v${parseInt(version || "0") + 1}`; - const redir = `https://nodes${prefix === "beta-dev" ? "-dev" : ""}.desci.com/dpid/${[ - request.dpid, - cleanVersion, - suffix, - ] - .filter(Boolean) - .join("/")}`; + const redir = `https://nodes${ + prefix === "beta-dev" || domain === "dev-beta.dpid.org" ? "-dev" : "" + }.desci.com/dpid/${[request.dpid, cleanVersion, suffix].filter(Boolean).join("/")}`; logger.info({ output }, "[dpid:resolve]"); return redir; }; diff --git a/src/index.ts b/src/index.ts index eda4988..dab2660 100644 --- a/src/index.ts +++ b/src/index.ts @@ -51,6 +51,7 @@ app.get("/*", async (req: Request, res: Response) => { prefix, raw: isRaw, jsonld: isJsonld, + domain: hostname, }; analytics.log({