Skip to content
On this page

Token-Based Authentication

nuxt-kql also supports using a bearer token for authentication. For this to work, you will have to use the kirby-headless-starter, which supports KQL with token authentication out of the box.

ts
// `nuxt.config.ts`
export default defineNuxtConfig({
  modules: ['nuxt-kql'],

  kql: {
    // Enable the token-based authentication
    auth: 'bearer',
    // Needed for the kirby-headless-starter custom KQL endpoint
    prefix: 'api/kql',
  },
})

Set the following environment variables in your project's .env file:

KIRBY_BASE_URL=https://kirby.example.com
KIRBY_API_TOKEN=your-token

INFO

Make sure to set the same token as the KIRBY_HEADLESS_API_TOKEN environment variable in your headless Kirby project's .env file.

Released under the MIT License.