Skip to content

Send KQL query for nuxt.config.ts? #14

Discussion options

You must be logged in to vote

Great question!

tl;dr: You can't. useKql is only available during a component's lifecycle; during the setup() phase of a component. Just like Nuxt's useFetch, useNuxtApp and other composables. Also, useKql needs the Nuxt instance to retrieve values like the Kirby backend URL from the runtime config.

However, you can create a custom module that fetches a query and adds routes to Nitro prerender queue.

Save the following module as modules/prerender.ts. Nuxt will auto-import the module. I assume you use the Kirby Headless plugin with the bearer-token authentication? If not, you have to adapt the authentication method for the $kirby fetch instance.

import { ofetch } from 'ofetch'
import { def…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SavioMenifer
Comment options

Answer selected by SavioMenifer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants