Closed Opyd closed 1 year ago
While trying to log with strategy: FetchError: Failed to execute 'fetch' on 'Window': Invalid value () What I'm missing?
FetchError: Failed to execute 'fetch' on 'Window': Invalid value ()
nuxt.config.ts:
export default defineNuxtConfig({ ssr: false, modules : [ '@nuxtjs-alt/auth', '@nuxtjs-alt/http', '@pinia/nuxt' ], http: { baseURL: 'http://127.0.0.1:3100/api' }, auth: { strategies: { local: { token: { property: 'accessToken', global: true, }, user: { property: 'user', }, endpoints: { login: { url: '/api/auth/login', method: 'post' }, logout: { url: '/api/auth/logout', method: 'post' }, user: { url: '/api/auth/user', method: 'get' } } } } } })
Click.vue:
<template> <button @click="click">Click</button> </template> <script setup lang="ts"> const {$auth} = useNuxtApp(); async function click(){ try { const res = await $auth.loginWith('local', { body: { username: 'test', password: 'test' } }) } catch (e){ console.log(e) } } </script> <style scoped> </style>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
While trying to log with strategy:
FetchError: Failed to execute 'fetch' on 'Window': Invalid value ()
What I'm missing?nuxt.config.ts:
Click.vue: