nuxt/icon

Default `/api` endpoint base route causes conflict with common path-forwarding rules

Closed this issue · 0 comments

Currently, icons are fetched from /api/_nuxt_icon/[collection].json, however, /api as a base path is commonly reserved for application-level APIs.

icon/src/module.ts

Lines 55 to 58 in 85a0e7b

addServerHandler({
route: '/api/_nuxt_icon/:collection',
handler: resolver.resolve('./runtime/server/api'),
})

It's not uncommon for larger applications with independent frontends and backends to have path-forwarding rules configured to forward any requests starting with a /api path to a backend service.

When this is the case, fetch requests sent to retrieve icons are sent to a completely different service and fail. It'd be nice to be able to override the default /api/_nuxt_icon path or at the very least use a less common default base path (perhaps just omit api altogether and use /_nuxt_icon/:collection - this would be much less likely to cause conflicts).