File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { basename } from 'pathe'
2
2
import { getIcons } from '@iconify/utils'
3
3
import { consola } from 'consola'
4
4
import { useAppConfig , defineCachedEventHandler } from 'nitropack/runtime'
5
+ import { createError } from 'h3'
5
6
import type { NuxtIconRuntimeOptions } from '../../schema-types'
6
7
import { collections } from '#nuxt-icon-server-bundle'
7
8
@@ -21,7 +22,7 @@ export default defineCachedEventHandler(async (ctx) => {
21
22
: null
22
23
23
24
const apiEndPoint = options . iconifyApiEndpoint || DEFAULT_ENDPOINT
24
- const apiUrl = new URL ( basename ( url ) , apiEndPoint )
25
+ const apiUrl = new URL ( './' + basename ( url ) , apiEndPoint )
25
26
const icons = apiUrl . searchParams . get ( 'icons' ) ?. split ( ',' )
26
27
27
28
if ( collection ) {
@@ -47,6 +48,9 @@ export default defineCachedEventHandler(async (ctx) => {
47
48
48
49
if ( options . fallbackToApi ) {
49
50
consola . debug ( `[Icon] fetching ${ ( icons || [ ] ) . map ( i => '`' + collectionName + ':' + i + '`' ) . join ( ',' ) } from iconify api` )
51
+ if ( apiUrl . host !== new URL ( apiEndPoint ) . host ) {
52
+ return createError ( { status : 400 , message : 'Invalid icon request' } )
53
+ }
50
54
const data = await $fetch ( apiUrl . href )
51
55
return data
52
56
}
You can’t perform that action at this time.
0 commit comments