Skip to content

Incorrect response of authorize API #119

@Fukao0129

Description

@Fukao0129

Environment

@nuxt-alt/auth 3.1.4
@nuxt-alt/http 1.7.10
node 18.18.2
npm 9.8.1
vue 3.3.8
nuxt 3.8.2

Nuxt Config

  auth: {
    stores: {
      state: {
        namespace: "auth",
      },
      pinia: {
        enabled: false,
      },
      cookie: {
        enabled: true,
        options: {
          maxAge: 31536000,
        },
      },
    },
    strategies: {
      local: {
        scheme: "local",
        url: process.env.API_URL,
        endpoints: {
          login: {
            baseURL: process.env.API_URL,
            url: "login",
            method: "post",
          },
          logout: {
            baseURL: process.env.API_URL,
            url: "logout",
            method: "post",
          },
          user: {
            baseURL: process.env.API_URL,
            url: "me",
            method: "get",
          },
        },
        user: {
          property: "data.attributes",
        },
        token: {
          property: "access_token",
          global: true,
          maxAge: 60 * 1,
        },
      },
    },
  },

Reproduction

Can't reproduce.

Describe the bug

When I try to login, '_auth/local/local1/authorize' API is called.

Its response is the html source of the page.
28b7b3c75f1cd36a38960f66654c338a

The response seems to be used as the me API's request header, and it fails.
0f0e16caa0adb687e69beb45c125a140

What should the response format of the authorize API be?

Additional context

■Login code

await this.$auth.loginWith("local", {
    body: {
        email: email@xxx,
        password: password,
    },
});

■The request body of the authorize API
aaa187d84b92527113b57095561ce793

Logs

FetchError: [GET] "http://localhost/api/v1/user/me?include=roles.permissions": <no response> Failed to execute 'fetch' on 'Window': Failed to read the 'headers' property from 'RequestInit': String contains non ISO-8859-1 code point.Caused by: TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'headers' property from 'RequestInit': String contains non ISO-8859-1 code point.
    at $fetchRaw2 (ofetch.js?v=3b6afd57:297:32)
    at onError (ofetch.js?v=3b6afd57:232:16)
    at AsyncFunction.$fetchRaw2 [as raw] (ofetch.js?v=3b6afd57:306:20)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions