becem-gharbi / nuxt-directus

Unofficial Directus client for Nuxt
MIT License
43 stars 9 forks source link

Invalid payload. \"refresh_token\" is required #46

Closed laportem closed 1 year ago

laportem commented 1 year ago

When I call the logout() composable I get the error below even though I actually get logged out. i.e the user is null. I'm using:

  "@bg-dev/nuxt-directus": "2.3.0-beta",
  "nuxt": "^3.6.5",

console.log is printing this


Uncaught (in promise) FetchError:  (400 Bad Request (http://127.0.0.1:8055/auth/logout))

and the network log is showing this error

message: "Invalid payload. \"refresh_token\" is required in either the JSON payload or Cookie."

I called logout as follows:

<script lang="ts" setup>
const { logout } = useDirectusAuth();
const handleSignout = async () => await logout();
</script>

<template>
  <div>
       <UButton label="Sign Out" @click="handleSignout"></UButton>
  </div>
<template>
becem-gharbi commented 1 year ago

This means that the refresh token cookie is not sent. Please make sure to read Auth section in docs.

laportem commented 1 year ago

I assumed you mean the Auth section in the Readme file. It is not clear where and how one would set the refresh token cookie. I'm actually following your starter template and do not see any settings or references to the refresh token cookie.

Can you point me to where and how I do this setting?

becem-gharbi commented 1 year ago

You just need to make sure that the domain name for both apps is the same

laportem commented 1 year ago

I see but for now i am testing your module on my dev localhost environment. So nuxt is running at http://localhost:3000/ Directus is running at http://localhost:8055/ in docker

my nuxt .env file is as follows:

DIRECTUS_REST_BASE_URL=http://127.0.0.1:8055
DIRECTUS_REST_NUXT_BASE_URL=http://127.0.0.1:3000
DIRECTUS_GRAPHQL_HTTP_ENDPOINT=http://127.0.0.1:8055/graphql
DIRECTUS_GRAPHQL_WS_ENDPOINT=ws://127.0.0.1:8055/graphql
DIRECTUS_DEFAULT_ROLE_ID=

not sure what else I am missing?

becem-gharbi commented 1 year ago

Related issue #38

becem-gharbi commented 1 year ago

New update on this issue https://github.com/becem-gharbi/nuxt-directus/releases/tag/v2.0.4