Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(api): update URL handling of resolved redirects (#2442)

tom9397bd4f191d
diff --git a/apps/api/src/lib/map-utils.ts b/apps/api/src/lib/map-utils.ts
index 3c2ae31e9..4c24a80fa 100644
--- a/apps/api/src/lib/map-utils.ts
+++ b/apps/api/src/lib/map-utils.ts
@@ -112,7 +112,15 @@ export async function getMapResults({
}): Promise<MapResult> {
const functionStartTime = Date.now();
- url = await resolveRedirects(url, abort);
+ const resolvedUrl = await resolveRedirects(url, abort);
+
+ // If the resolved URL is on a different domain, replace the hostname
+ if (!isSameDomain(url, resolvedUrl)) {
+ const urlObj = new URL(url);
+ urlObj.hostname = new URL(resolvedUrl).hostname;
+
+ url = urlObj.toString();
+ }
const id = uuidv4();
let mapResults: MapDocument[] = [];