The Custom Schema doesn't work and an error is shown in the browser's console.
client.js?06a0:102 TypeError: Class constructor LocalScheme cannot be invoked without 'new'
at new StrapiScheme (strapi.js?6967:5)
at eval (auth.js?e25e:44)
at _callee2$ (index.js?f26e:59)
at tryCatch (runtime.js?96cf:63)
at Generator.invoke [as _invoke] (runtime.js?96cf:293)
at Generator.eval [as next] (runtime.js?96cf:118)
at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
at _next (asyncToGenerator.js?1da1:25)
Steps to reproduce
install lastest nuxt w/ strapi and auth-next
for this example, I've added tailwindcss too
create a custom schema for strapi integration
// https://auth.nuxtjs.org/guide/scheme#creating-your-own-scheme
import { LocalScheme } from '~auth/runtime'
export default class StrapiScheme extends LocalScheme {
async login(data, { reset = true } = {}) {
// Ditch any leftover local tokens before attempting to log in
if (reset) {
this.$auth.reset({ resetInterceptor: false })
}
const { $strapi } = this.$auth.ctx
// Make login request
const response = await $strapi.login(data)
// update token
this.updateTokens({
data: {
token: response.jwt,
},
})
// Initialize request interceptor if not initialized
if (!this.requestHandler.interceptor) {
this.initializeRequestInterceptor()
}
// Fetch user if `autoFetch` is enabled
if (this.options.user.autoFetch) {
this.$auth.setUser(response.user)
}
return response
}
fetchUser(_endpoint) {
// remove this feature b/c strapi already do it itselft
// https://strapi.nuxtjs.org/strapi#fetchuser
return Promise.resolve()
}
async logout(_endpoint) {
// Only connect to logout endpoint if it's configured
await this.$auth.ctx.$strapi.logout()
// But reset regardless
return this.$auth.reset()
}
}
Version
module: 5.0.0-1622018627.48534b6 nuxt: 2.15.6
Nuxt configuration
Nuxt configuration
Reproduction
https://github.com/derevandal/nuxt-strapi-auth-next
What is expected?
The Custom Schema should work properly.
What is actually happening?
The Custom Schema doesn't work and an error is shown in the browser's console.
Steps to reproduce
Additional information
Checklist