Skip to content

Upgrade to 0.10.0

This release contains breaking changes for the default middleware and the configuration of baseURL and AUTH_ORIGIN

Installation

bash
npm i -D @sidebase/nuxt-auth@^0.10.0
bash
pnpm i -D @sidebase/nuxt-auth@^0.10.0
bash
yarn add --dev @sidebase/nuxt-auth@^0.10.0

Breaking Changes

Renaming of default middleware

In 0.10.0 we renamed the included middleware from auth to sidebase-auth. This is a quality of life change to allow developers to create their own custom middleware named auth.global.ts without conflicting with the provided middleware.

If you use the auth middleware inline on any of your pages you will need to rename it:

vue
<script lang="ts" setup>
definePageMeta({
  middleware: 'auth', 
  middleware: 'sidebase-auth', 
})
</script>

<template>
  Only I am protected!
</template>

Adjustments to the computation of baseURL and AUTH_ORIGIN

In 0.10.0 we spent a considerable amount of time reworking how @sidebase/nuxt-auth determines which endpoints to make requests to. If you would like to view the full PR and discussion, you can find it here.

Read more in a dedicated guide.

Below are some notable changes.

URLs are now joined

baseURL now means exactly that, it will be prepended to a path before making a call. That means you need to adjust your config accordingly:

ts
export default defineNuxtConfig({
  auth: {
    baseURL: 'https://example.com', 
    baseURL: 'https://example.com/api/auth', 

    provider: {
      type: 'local',
      endpoints: {
        signIn: { path: '/login', method: 'post' },
      }
    }
  }
})

Adjustments when using an external backend for the local-provider

In previous versions of @sidebase/nuxt-auth a very specific setup was needed to ensure that external backends could properly be used for the local provider. In 0.10.0 we reworked the internal handling or URLs to make it more consistent across providers and configurations.

If you were previously using an external backend, you can now prefix endpoint paths with a /:

ts
export default defineNuxtConfig({
  auth: {
    provider: {
      type: 'local',
      endpoints: {
        signIn: { path: 'login', method: 'post' }, 
        signIn: { path: '/login', method: 'post' }, 
        getSession: { path: 'session', method: 'get' }, 
        getSession: { path: '/session', method: 'get' }, 
      }
    }
  }
})

Therefore as of version 0.10.0, we recommend the following setup to set your AUTH_ORIGIN or baseURL:

ts
export default defineNuxtConfig({
  // ... other configuration
  auth: {
    baseUrl: 'https://my-backend.com/api/auth', 
    // This is technically not needed as it is the default, but it's here for illustrative purposes
    originEnvKey: 'AUTH_ORIGIN', 
  }
})
env
AUTH_ORIGIN="https://my-backend.com/api/auth"

Changelog

Full Changelog: https://github.com/sidebase/nuxt-auth/compare/0.9.4...0.10.0

Released under the MIT License.