I am testing Nuxt 5 compatibility and found this module is using useAppConfig in nitro side. useAppConfig is removed in nitro v3, which make the api import a not exist function and crash the Nuxt 5 app.
Reproduction: https://stackblitz.com/edit/github-nzhlgyg3?file=nuxt.config.ts
Perhaps we need to consider moving some of the configuration (e.g. iconifyApiEndpoint and fallbackToApi) to nuxt.config.
Reference:
temporary solution for nuxt 5 nightly
Apply this diff to the module if you use default value of iconifyApiEndpoint and fallbackToApi config:
diff --git a/dist/runtime/server/api.js b/dist/runtime/server/api.js
index 3685dcb9e566d70d675d6557c95106dddff1d6d2..e9c1c639764d898ee12f56bcfdcd05a2361ccc95 100644
--- a/dist/runtime/server/api.js
+++ b/dist/runtime/server/api.js
@@ -1,9 +1,9 @@
import { getIcons } from "@iconify/utils";
import { hash } from "ohash";
-import { createError } from "h3";
+import { defineCachedHandler } from "nitro/cache";
+import { createError } from "nitro/h3";
import { parseQuery, parsePath } from "ufo";
import { consola } from "consola";
-import { useAppConfig, defineCachedEventHandler } from "#imports";
import { collections } from "#nuxt-icon-server-bundle";
const warnOnceSet = /* @__PURE__ */ new Set();
const DEFAULT_ENDPOINT = "https://api.iconify.design";
@@ -14,8 +14,8 @@ function getInstallCommand(pkg) {
if (ua.startsWith("bun")) return `bun add -D ${pkg}`;
return `npm i -D ${pkg}`;
}
-export default defineCachedEventHandler(async (event) => {
- const options = useAppConfig().icon;
+export default defineCachedHandler(async (event) => {
+ const options = { fallbackToApi: true };
const collectionName = event.context.params?.collection?.replace(/\.json$/, "");
const collection = collectionName && Object.hasOwn(collections, collectionName) ? await collections[collectionName]?.() : null;
const apiEndPoint = options.iconifyApiEndpoint || DEFAULT_ENDPOINT;
I am testing Nuxt 5 compatibility and found this module is using
useAppConfigin nitro side.useAppConfigis removed in nitro v3, which make the api import a not exist function and crash the Nuxt 5 app.Reproduction: https://stackblitz.com/edit/github-nzhlgyg3?file=nuxt.config.ts
Perhaps we need to consider moving some of the configuration (e.g.
iconifyApiEndpointandfallbackToApi) to nuxt.config.Reference:
customizeglobally #428ENOENT: .nuxt/imports) #467temporary solution for nuxt 5 nightly
Apply this diff to the module if you use default value of
iconifyApiEndpointandfallbackToApiconfig: