nuxt-ai-ready 0.7.15 → 0.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "aiReady",
7
- "version": "0.7.15",
7
+ "version": "0.7.16",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -7,14 +7,14 @@ export interface IndexNowResult {
7
7
  backoff?: boolean;
8
8
  }
9
9
  /**
10
- * Submit URLs to IndexNow API
10
+ * Submit URLs to IndexNow API with fallback on rate limit
11
11
  */
12
12
  export declare function submitToIndexNow(routes: string[], config: {
13
13
  key: string;
14
- host?: string;
15
14
  }, siteUrl: string): Promise<{
16
15
  success: boolean;
17
16
  error?: string;
17
+ host?: string;
18
18
  }>;
19
19
  /**
20
20
  * Submit pending pages to IndexNow
@@ -30,12 +30,11 @@ async function setBackoffInfo(event, info) {
30
30
  await db.exec("DELETE FROM _ai_ready_info WHERE id = ?", ["indexnow_backoff"]);
31
31
  }
32
32
  }
33
+ const INDEXNOW_HOSTS = ["api.indexnow.org", "www.bing.com"];
33
34
  export async function submitToIndexNow(routes, config, siteUrl) {
34
35
  if (!siteUrl) {
35
36
  return { success: false, error: "Site URL not configured" };
36
37
  }
37
- const host = config.host || "api.indexnow.org";
38
- const endpoint = `https://${host}/indexnow`;
39
38
  const urlList = routes.map(
40
39
  (route) => route.startsWith("http") ? route : `${siteUrl}${route}`
41
40
  );
@@ -45,18 +44,28 @@ export async function submitToIndexNow(routes, config, siteUrl) {
45
44
  keyLocation: `${siteUrl}/${config.key}.txt`,
46
45
  urlList
47
46
  };
48
- logger.debug(`[indexnow] Submitting ${urlList.length} URLs to ${endpoint}`);
49
- const response = await $fetch(endpoint, {
50
- method: "POST",
51
- headers: { "Content-Type": "application/json" },
52
- body
53
- }).catch((err) => ({ error: err.message }));
54
- if (response && typeof response === "object" && "error" in response) {
55
- logger.warn(`[indexnow] Submission failed: ${response.error}`);
56
- return { success: false, error: response.error };
47
+ let lastError;
48
+ for (const host of INDEXNOW_HOSTS) {
49
+ const endpoint = `https://${host}/indexnow`;
50
+ logger.debug(`[indexnow] Submitting ${urlList.length} URLs to ${endpoint}`);
51
+ const response = await $fetch(endpoint, {
52
+ method: "POST",
53
+ headers: { "Content-Type": "application/json" },
54
+ body
55
+ }).catch((err) => ({ error: err.message }));
56
+ if (response && typeof response === "object" && "error" in response) {
57
+ lastError = response.error;
58
+ if (lastError.includes("429")) {
59
+ logger.warn(`[indexnow] Rate limited on ${host}, trying fallback...`);
60
+ continue;
61
+ }
62
+ logger.warn(`[indexnow] Submission failed on ${host}: ${lastError}`);
63
+ return { success: false, error: lastError, host };
64
+ }
65
+ logger.debug(`[indexnow] Successfully submitted ${urlList.length} URLs via ${host}`);
66
+ return { success: true, host };
57
67
  }
58
- logger.debug(`[indexnow] Successfully submitted ${urlList.length} URLs`);
59
- return { success: true };
68
+ return { success: false, error: lastError || "All endpoints rate limited", host: INDEXNOW_HOSTS[INDEXNOW_HOSTS.length - 1] };
60
69
  }
61
70
  export async function syncToIndexNow(event, limit = 100) {
62
71
  const config = useRuntimeConfig(event)["nuxt-ai-ready"];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ai-ready",
3
3
  "type": "module",
4
- "version": "0.7.15",
4
+ "version": "0.7.16",
5
5
  "description": "Best practice AI & LLM discoverability for Nuxt sites.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",