Skip to content

WeEndpointSwitcher ​

Hidden, password-protected dialog to switch the API base URL at runtime (e.g. to point a production build at a test backend) and to toggle XDebug. It uses useApiUrl: the choice is stored in localStorage and the page is reloaded on save.

The component renders only its activator slot: the dialog opens after 5 clicks on it. The dialog is then locked until the password is entered.

Usage ​

vue
<template>
  <we-endpoint-switcher>
    <template #activator="{ attrs }">
      <img src="/logo.svg" alt="logo" v-bind="attrs">
    </template>
  </we-endpoint-switcher>
</template>

The dialog lists the URLs in we.api.endpoints and has a free text field for any other URL:

ts
// nuxt.config.ts
export default defineNuxtConfig({
  we: {
    api: {
      endpoints: ['https://api.example.com', 'https://api-test.example.com'],
    },
  },
})
  • Save calls changeBaseUrl(url), which stores the URL and reloads the page
  • The XDebug switch applies immediately (changeXDebug), without reloading

Props ​

PropTypeDefaultDescription
passwordstring'letmein'Password required to unlock the dialog

Slots ​

NamePropsDescription
activator{ attrs: { onClick } }Element that opens the dialog; bind attrs to it. Every click counts, the 5th opens the dialog

Source Code ​