export default defineNitroPlugin((nitroApp) => {
  const base = useRuntimeConfig().quibotBaseUrl
  nitroApp.hooks.hook('request', (event) => {
    const url = getCookie(event, 'quibot-pi-url')
    if (url && url !== decodeURIComponent(base)) {
      // Override the base URL for this request
      (event.context as any).__piBaseUrl = url
    }
  })
})
