manchenkoff / nuxt-auth-sanctum

Nuxt module for Laravel Sanctum authentication
https://manchenkoff.gitbook.io/nuxt-auth-sanctum/
MIT License
163 stars 21 forks source link

Could not convert argument of type symbol to string #183

Closed ahoiroman closed 3 weeks ago

ahoiroman commented 3 weeks ago

Describe the bug

After running nuxi upgrade, I am getting the following error:

[nuxt-auth-sanctum:ssr]  ERROR  Unable to load user identity from API [GET] "http://web.example.test/backend/api/user/current": <no response> Could not convert argument of type symbol to string.

  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async $fetch2 (node_modules/.pnpm/ofetch@1.4.0/node_modules/ofetch/dist/shared/ofetch.4747642d.mjs:304:15)
  at async initialIdentityLoad (node_modules/.pnpm/nuxt-auth-sanctum@0.4.14_magicast@0.3.5_rollup@4.22.5/node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:48:20)
  at async node_modules/.pnpm/nuxt-auth-sanctum@0.4.14_magicast@0.3.5_rollup@4.22.5/node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:74:113
  at async setup (virtual:nuxt:/Users/ahoi/Entwicklung/Nuxt/simpli-frontend/.nuxt/plugins/server.mjs:69:116)
  at async Object.callAsync (node_modules/.pnpm/unctx@2.3.1/node_modules/unctx/dist/index.mjs:72:16)
  at async applyPlugin (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/nuxt.js:146:25)
  at async executePlugin (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/nuxt.js:183:9)
  at async Module.applyPlugins (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/nuxt.js:197:5)
  at async createNuxtAppServer (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/entry.js:24:7)

If I perform that call manually using curl, I am getting:

http get http://web.example.test/backend/api/user/current
HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Type: application/json
Date: Mon, 30 Sep 2024 19:59:33 GMT
Server: nginx/1.25.4
Transfer-Encoding: chunked
access-control-allow-origin: *
cache-control: no-cache, private
x-powered-by: PHP/8.3.11

{
    "message": "Unauthenticated."
}

Expected behavior

HTTP 200 or 401 response

Actual behavior

Error

Module information 0.4.14


manchenkoff commented 3 weeks ago

Hey @ahoiroman, it looks like there might be interference because of routeRules defined in your nuxt.config.ts, could you share its content?

ahoiroman commented 3 weeks ago

Sure:

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  extends: ['@nuxt/ui-pro'],

  modules: [
    '@nuxt/content',
    '@nuxt/eslint',
    '@nuxt/fonts',
    '@nuxt/image',
    '@nuxt/ui',
    '@nuxthq/studio',
    '@vueuse/nuxt',
    'nuxt-og-image',
    'nuxt-auth-sanctum',
    '@nuxtjs/i18n'
  ],

  hooks: {
    // Define `@nuxt/ui` components as global to use them in `.md` (feel free to add those you need)
    'components:extend': (components) => {
      const globals = components.filter(c => ['UButton'].includes(c.pascalName))

      globals.forEach(c => c.global = true)
    }
  },

  runtimeConfig: {
    backendUrl: process.env.NUXT_BACKEND_URL,
    apiVersion: process.env.NUXT_API_VERSION,
    public: {
      siteUrl: process.env.NUXT_PUBLIC_SITE_URL,
      sanctum: {
        baseUrl: `${process.env.NUXT_PUBLIC_SITE_URL}/backend`
      },
    }
  },

  sanctum: {
    endpoints: {
      csrf: '/sanctum/csrf-cookie',
      login: '/login',
      logout: '/logout',
      user: '/api/user/current'
    },
    redirect: {
      onGuestOnly: '/dashboard'
    }
  },

  routeRules: {
    // Temporary workaround for prerender regression. see https://github.com/nuxt/nuxt/issues/27490
    '/': { prerender: true },
    '/api/search.json': { prerender: true },
    '/backend/**': {
      proxy: {
        to: `${process.env.NUXT_BACKEND_URL}/**`,
        headers: { accept: 'application/json' }
      }
    },
    '/backend/api/**': {
      proxy: {
        to: `${process.env.NUXT_BACKEND_URL}/api/${process.env.NUXT_API_VERSION}/**`,
        headers: { accept: 'application/json' }
      }
    }
  },

  devtools: {
    enabled: true
  },

  typescript: {
    strict: false
  },

  colorMode: {
    disableTransition: true
  },

  future: {
    compatibilityVersion: 4
  },

  eslint: {
    config: {
      stylistic: {
        commaDangle: 'never',
        braceStyle: '1tbs'
      }
    }
  },

  compatibilityDate: '2024-07-11'
})

But the same issue occurs if I set the original endpoint without using routeRules.

In this case it's

[nuxt-auth-sanctum:ssr]  ERROR  Unable to load user identity from API [GET] "http://api.example.test/api/v1/user/current": <no response> Could not convert argument of type symbol to string.

One thing really bugs me: I cannot see the request in Laravel Telescope. If I perform the call from terminal app, I am getting this result:

http http://api.example.test/api/v1/user/current Accept:application/json
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Origin: *
Cache-Control: no-cache, private
Connection: keep-alive
Content-Type: application/json
Date: Mon, 30 Sep 2024 20:37:52 GMT
Server: nginx/1.25.4
Transfer-Encoding: chunked
X-Powered-By: PHP/8.3.11

{
    "message": "Unauthenticated."
}

or (with route rules):

http get http://web.example.test/backend/api/user/current Accept:application/json
HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Type: application/json
Date: Mon, 30 Sep 2024 20:39:21 GMT
Server: nginx/1.25.4
Transfer-Encoding: chunked
access-control-allow-origin: *
cache-control: no-cache, private
x-powered-by: PHP/8.3.11

{
    "message": "Unauthenticated."
}
manchenkoff commented 3 weeks ago

If I perform the call from CLI

What do you mean by that?

Could you also try these 2 things:

ahoiroman commented 3 weeks ago

Hi,

What do you mean by that?

I meant using the terminal app and httpie/curl. Those requests do work. But those requests need to set theAccept:application/json header, otherwise they won't return a value but crash with RouteNotFoundException as lluminate\Auth\Middleware\Authenticate:unauthenticated tries to redirect to the login route, if the request does not expectJson (https://github.com/illuminate/auth/blob/master/Middleware/Authenticate.php#L100-L107).

remove headers from routeRules

Did not work, same error. And I'd need to set those headers, because Laravel would try to redirect to /login otherwise.

disable SSR and check if the issue persist

Not using ssr does indeed work. But the rest of my application does not work as expected.

manchenkoff commented 3 weeks ago

@ahoiroman I see, if CSR works without this issue, then our problem is most probably related to headers passed in SSR mode. Could you please register this interceptor in your app.config.ts? It might help us to understand what the problematic value is.

sanctum: {
    interceptors: {
      onRequest: async (
        app: NuxtApp,
        ctx: FetchContext,
        logger: ConsolaInstance,
      ) => {
        logger.info(
          `Request headers for "${ctx.request.toString()}"`,
          ctx.options.headers,
        )
      },
    },
  }

You can find an example here or in the docs here.

ahoiroman commented 3 weeks ago

Sure. This is the result:

[nuxt-auth-sanctum:ssr] ℹ Request headers for "/api/user/current" { Accept: 'application/json',
  Referer: 'http://web.example.test',
  Origin: 'http://web.example.test',
  cookie:
   'laravel_session=eyJpdiI6InZLWURRNmNtWEU4ZVRFU3ZFdmxMd1E9PSIsInZhbHVlIjoiNkhvUDlVNnE3N0xsMHhOeGsyL2piWXRCL2V4UU55M01MTVg5dVZ2dEdrL2RmM2NSczlINjdONXlOcU1FblhHNjY5ZUdRbkZXMWpmVUVROXVsRDVwOUVSaEJOVVNwM210dDVCQ2VXM3dBYVdTeEU3QjZuVkFXc2puV1hSdjJ6aDUiLCJtYWMiOiI1NjE4NmQ5MDVkYzM5MGUwNTY4ZTNmZjUxM2I0MmFhMTBmM2FkNzNjMmFkNjZiYTkyMDQ0ZDUzZmVhZmVjYTE3IiwidGFnIjoiIn0%3D; i18n_redirected=en',
  'user-agent':
   'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
  [Symbol(headers list)]:
   HeadersList {
     cookies: null,
     [Symbol(headers map)]: Map(0) {},
     [Symbol(headers map sorted)]: null },
  [Symbol(guard)]: 'none' }

[nuxt-auth-sanctum:ssr]  ERROR  Unable to load user identity from API [GET] "http://web.example.test/backend/api/user/current": <no response> Could not convert argument of type symbol to string.

  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async $fetch2 (node_modules/.pnpm/ofetch@1.4.0/node_modules/ofetch/dist/shared/ofetch.4747642d.mjs:304:15)
  at async initialIdentityLoad (node_modules/.pnpm/nuxt-auth-sanctum@0.4.14_magicast@0.3.5_rollup@4.22.5/node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:48:20)
  at async node_modules/.pnpm/nuxt-auth-sanctum@0.4.14_magicast@0.3.5_rollup@4.22.5/node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:75:113
  at async setup (virtual:nuxt:/Users/ahoi/Entwicklung/Nuxt/example-frontend/.nuxt/plugins/server.mjs:69:116)
  at async Object.callAsync (node_modules/.pnpm/unctx@2.3.1/node_modules/unctx/dist/index.mjs:72:16)
  at async applyPlugin (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/nuxt.js:146:25)
  at async executePlugin (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/nuxt.js:183:9)
  at async Module.applyPlugins (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/nuxt.js:197:5)
  at async createNuxtAppServer (node_modules/.pnpm/nuxt@3.13.2_@parcel+watcher@2.4.1_@types+node@22.7.4_eslint@9.11.1_jiti@2.0.0__ioredis@5.4.1__kbqzpk2u3fvus3amz6lso723jm/node_modules/nuxt/dist/app/entry.js:24:7)

or

[nuxt-auth-sanctum:ssr] ℹ Request headers for "/api/user/current" { Accept: 'application/json',
  Referer: 'http://web.example.test',
  Origin: 'http://web.example.test',
  cookie:
   'XSRF-TOKEN=eyJpdiI6IlF4ZDZPQjZSOU5uZk0yRUlIeU4ybkE9PSIsInZhbHVlIjoiejR4Z0k3Y2VDQkc0TzZpMWJUYVVZUHg0ekRiNEw0NkZBWDlkakxaNnZWRUpSS0x5ck9IendsZFp0R3J0NE1HYVptbzZpU09xQmlsRGM0ZEJkajUrTGowaGN2MTM1R2NMbzhtR041ZUdzU3hqNHdPTEROSitJKzQxMng5dU0zVFAiLCJtYWMiOiIyZjVjZWJkNTljYzM4OTJjZGJjNWNmZGNmYzU4Y2NlYWFiYjQ5NDQzZTY1NWNmYjNiYjZlNjAyYWI1ODhhYmIwIiwidGFnIjoiIn0%3D; laravel_session=eyJpdiI6InlsQlpLUGtxc1BITllZVVljbXRTU1E9PSIsInZhbHVlIjoiQVdLTUkyTWtqVm1RaGVDQnNKYzFJdlJRUWNUQVZNTUhJa3E5OHNrRXhWQUY5ZTFQWU1JZlE0clNPajIrMGpsb2FRY0YySHVGbGNpSzhsa0wreHg2NXU5ZGxPVGNtR1BqS2Jvc21STjVoZHFLb2gwdzVJMHhreGV0Y1dITkhpVXgiLCJtYWMiOiI0NDFlOWU4N2Q4OWY2OTQ2OWIzMmFkY2QxMGMyZTc2MmZmN2EyMjA1MjUzNDNiMjJkNzhkMGUzOTNhNzc2MmQ2IiwidGFnIjoiIn0%3D; i18n_redirected=en',
  'user-agent':
   'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
  [Symbol(headers list)]:
   HeadersList {
     cookies: null,
     [Symbol(headers map)]: Map(0) {},
     [Symbol(headers map sorted)]: null },
  [Symbol(guard)]: 'none' }

It also seems like Accept: 'application/json' is set, even if I don't set it in the routeRules.

manchenkoff commented 3 weeks ago

Thanks @ahoiroman, indeed you have some weird entry there whose origin I am not sure about yet 🤔

[Symbol(headers list)]:
   HeadersList {
     cookies: null,
     [Symbol(headers map)]: Map(0) {},
     [Symbol(headers map sorted)]: null },
  [Symbol(guard)]: 'none'

It cannot be automatically converted to the proper key-value pair, thus you end up with a broken request that doesn't reach the API.

My module only takes care of the following headers:

I will try to check out the possible reasons of the interference but I am almost sure that the problem is in routeRules 😄

ahoiroman commented 3 weeks ago

Thanks (as always) for your efforts.

As I just created that project today, the package list could be something that helps you out:

~/Entwicklung/Nuxt/exaple-frontend git:[next_gen]
pnpm list --depth=1
Legend: production dependency, optional only, dev only

nuxt-ui-pro-template-saas /Users/ahoi/Entwicklung/Nuxt/example-frontend (PRIVATE)

dependencies:
@iconify-json/heroicons 1.2.0
└── @iconify/types 2.0.0
@iconify-json/simple-icons 1.2.4
└── @iconify/types 2.0.0
@nuxt/content 2.13.2
├── @nuxt/kit 3.13.2
├── @nuxtjs/mdc 0.8.3
├── @vueuse/core 10.11.1
├── @vueuse/head 2.0.0
├── @vueuse/nuxt 10.11.1
├── consola 3.2.3
├── defu 6.1.4
├── destr 2.0.3
├── json5 2.2.3
├── knitwork 1.1.0
├── listhen 1.8.0
├── mdast-util-to-string 4.0.0
├── mdurl 2.0.0
├── micromark 4.0.0
├── micromark-util-sanitize-uri 2.0.0
├── micromark-util-types 2.0.0
├── minisearch 7.1.0
├── ohash 1.1.4
├── pathe 1.1.2
├── scule 1.3.0
├── shiki 1.21.0
├── slugify 1.6.6
├── socket.io-client 4.8.0
├── ufo 1.5.4
├── unist-util-stringify-position 4.0.0
├── unstorage 1.12.0
└── ws 8.18.0
@nuxt/fonts 0.9.2
├── @nuxt/devtools-kit 1.5.1
├── @nuxt/kit 3.13.2
├── chalk 5.3.0
├── css-tree 3.0.0
├── defu 6.1.4
├── esbuild 0.24.0
├── fontaine 0.5.0
├── h3 1.12.0
├── jiti 1.21.6
├── magic-regexp 0.8.0
├── magic-string 0.30.11
├── node-fetch-native 1.6.4
├── ohash 1.1.4
├── pathe 1.1.2
├── sirv 2.0.4
├── tinyglobby 0.2.7
├── ufo 1.5.4
├── unplugin 1.14.1
└── unstorage 1.12.0
@nuxt/image 1.8.0
├── @nuxt/kit 3.13.2
├── consola 3.2.3
├── defu 6.1.4
├── h3 1.12.0
├── image-meta 0.2.1
├── ipx 2.1.0
├── node-fetch-native 1.6.4
├── ohash 1.1.4
├── pathe 1.1.2
├── std-env 3.7.0
└── ufo 1.5.4
@nuxt/ui-pro 1.4.3
├── @iconify-json/vscode-icons 1.2.2
├── @nuxt/ui 2.18.6
├── @vueuse/core 11.1.0
├── defu 6.1.4
├── git-url-parse 15.0.0
├── ofetch 1.4.0
├── parse-git-config 3.0.0
├── pathe 1.1.2
├── pkg-types 1.2.0
├── tailwind-merge 2.5.2
└── vue3-smooth-dnd 0.0.6
@nuxtjs/i18n 8.5.5
├── @intlify/h3 0.5.0
├── @intlify/shared 9.14.1
├── @intlify/unplugin-vue-i18n 3.0.1
├── @intlify/utils 0.12.0
├── @miyaneee/rollup-plugin-json5 1.2.0
├── @nuxt/kit 3.13.2
├── @rollup/plugin-yaml 4.1.2
├── @vue/compiler-sfc 3.5.10
├── debug 4.3.7
├── defu 6.1.4
├── estree-walker 3.0.3
├── is-https 4.0.0
├── knitwork 1.1.0
├── magic-string 0.30.11
├── mlly 1.7.1
├── pathe 1.1.2
├── scule 1.3.0
├── sucrase 3.35.0
├── ufo 1.5.4
├── unplugin 1.14.1
├── vue-i18n 9.14.1
└── vue-router 4.4.5
@vueuse/nuxt 11.1.0
├── @nuxt/kit 3.13.2
├── @vueuse/core 11.1.0
├── @vueuse/metadata 11.1.0
├── local-pkg 0.5.0
├── nuxt 3.13.2 peer
└── vue-demi 0.14.10
nuxt 3.13.2
├── @nuxt/devalue 2.0.2
├── @nuxt/devtools 1.5.1
├── @nuxt/kit 3.13.2
├── @nuxt/schema 3.13.2
├── @nuxt/telemetry 2.6.0
├── @nuxt/vite-builder 3.13.2
├── @parcel/watcher 2.4.1 peer
├── @types/node 22.7.4 peer
├── @unhead/dom 1.11.7
├── @unhead/shared 1.11.7
├── @unhead/ssr 1.11.7
├── @unhead/vue 1.11.7
├── @vue/shared 3.5.10
├── acorn 8.12.1
├── c12 1.11.2
├── chokidar 3.6.0
├── compatx 0.1.8
├── consola 3.2.3
├── cookie-es 1.2.2
├── defu 6.1.4
├── destr 2.0.3
├── devalue 5.1.1
├── errx 0.1.0
├── esbuild 0.23.1
├── escape-string-regexp 5.0.0
├── estree-walker 3.0.3
├── globby 14.0.2
├── h3 1.12.0
├── hookable 5.5.3
├── ignore 5.3.2
├── impound 0.1.0
├── jiti 1.21.6
├── klona 2.0.6
├── knitwork 1.1.0
├── magic-string 0.30.11
├── mlly 1.7.1
├── nanotar 0.1.1
├── nitropack 2.9.7
├── nuxi 3.14.0
├── nypm 0.3.12
├── ofetch 1.4.0
├── ohash 1.1.4
├── pathe 1.1.2
├── perfect-debounce 1.0.0
├── pkg-types 1.2.0
├── radix3 1.1.2
├── scule 1.3.0
├── semver 7.6.3
├── std-env 3.7.0
├── strip-literal 2.1.0
├── tinyglobby 0.2.6
├── ufo 1.5.4
├── ultrahtml 1.5.3
├── uncrypto 0.1.3
├── unctx 2.3.1
├── unenv 1.10.0
├── unhead 1.11.7
├── unimport 3.13.1
├── unplugin 1.14.1
├── unplugin-vue-router 0.10.8
├── unstorage 1.12.0
├── untyped 1.5.0
├── vue 3.5.10
├── vue-bundle-renderer 2.1.1
├── vue-devtools-stub 0.1.0
└── vue-router 4.4.5
nuxt-auth-sanctum 0.4.14
├── @nuxt/kit 3.13.2
└── defu 6.1.4
nuxt-og-image 3.0.4
├── @nuxt/devtools-kit 1.5.1
├── @nuxt/kit 3.13.2
├── @resvg/resvg-js 2.6.2
├── @resvg/resvg-wasm 2.6.2
├── @unocss/core 0.63.1
├── @unocss/preset-wind 0.63.1
├── chrome-launcher 1.1.2
├── defu 6.1.4
├── execa 9.4.0
├── image-size 1.1.1
├── magic-string 0.30.11
├── nuxt-site-config 2.2.18
├── nuxt-site-config-kit 2.2.18
├── nypm 0.3.12
├── ofetch 1.4.0
├── ohash 1.1.4
├── pathe 1.1.2
├── pkg-types 1.2.0
├── playwright-core 1.47.2
├── radix3 1.1.2
├── satori 0.11.1
├── satori-html 0.3.2
├── sirv 2.0.4
├── std-env 3.7.0
├── strip-literal 2.1.0
├── ufo 1.5.4
├── unplugin 1.14.1
├── unwasm 0.3.9
└── yoga-wasm-web 0.3.3
valibot 0.42.1
└── typescript 5.6.2 peer

devDependencies:
@nuxt/eslint 0.5.7
├── @eslint/config-inspector 0.5.4
├── @nuxt/devtools-kit 1.5.1
├── @nuxt/eslint-config 0.5.7
├── @nuxt/eslint-plugin 0.5.7
├── @nuxt/kit 3.13.2
├── chokidar 3.6.0
├── eslint 9.11.1 peer
├── eslint-flat-config-utils 0.4.0
├── eslint-typegen 0.3.2
├── find-up 7.0.0
├── get-port-please 3.1.2
├── mlly 1.7.1
├── pathe 1.1.2
└── unimport 3.13.1
@nuxthq/studio 2.1.1
├── @nuxt/kit 3.13.2
├── defu 6.1.4
├── git-url-parse 15.0.0
├── nuxt-component-meta 0.8.2
├── parse-git-config 3.0.0
├── pkg-types 1.2.0
├── socket.io-client 4.8.0
├── ufo 1.5.4
└── untyped 1.5.0
eslint 9.11.1
├── @eslint-community/eslint-utils 4.4.0
├── @eslint-community/regexpp 4.11.1
├── @eslint/config-array 0.18.0
├── @eslint/core 0.6.0
├── @eslint/eslintrc 3.1.0
├── @eslint/js 9.11.1
├── @eslint/plugin-kit 0.2.0
├── @humanwhocodes/module-importer 1.0.1
├── @humanwhocodes/retry 0.3.0
├── @nodelib/fs.walk 1.2.8
├── @types/estree 1.0.6
├── @types/json-schema 7.0.15
├── ajv 6.12.6
├── chalk 4.1.2
├── cross-spawn 7.0.3
├── debug 4.3.7
├── escape-string-regexp 4.0.0
├── eslint-scope 8.1.0
├── eslint-visitor-keys 4.1.0
├── espree 10.2.0
├── esquery 1.6.0
├── esutils 2.0.3
├── fast-deep-equal 3.1.3
├── file-entry-cache 8.0.0
├── find-up 5.0.0
├── glob-parent 6.0.2
├── ignore 5.3.2
├── imurmurhash 0.1.4
├── is-glob 4.0.3
├── is-path-inside 3.0.3
├── jiti 2.0.0 peer
├── json-stable-stringify-without-jsonify 1.0.1
├── lodash.merge 4.6.2
├── minimatch 3.1.2
├── natural-compare 1.4.0
├── optionator 0.9.4
├── strip-ansi 6.0.1
└── text-table 0.2.0
vue-tsc 2.1.6
├── @volar/typescript 2.4.5
├── @vue/language-core 2.1.6
├── semver 7.6.3
└── typescript 5.6.2 peer
calebwaldner commented 3 weeks ago

I'm think I may be experiencing this same error in my Dev environment currently. Using DigitalOcean App Platform to host Nuxt 3 front end and Laravel Forge for the backend.

My DigitalOcean front end Runtime Logs show a similar error:

[afleurist-web] [2024-09-30 23:01:25] Unable to load user identity from API FetchError: [GET] "https://dev-api.afleurist.com/api/users/me": <no response> Could not convert argument of type symbol to string.
[afleurist-web] [2024-09-30 23:01:25]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[afleurist-web] [2024-09-30 23:01:25]     at async $fetch2 (file:///workspace/.output/server/chunks/runtime.mjs:3716:15)
[afleurist-web] [2024-09-30 23:01:25]     at async initialIdentityLoad (file:///workspace/.output/server/chunks/build/server.mjs:1889:20)
[afleurist-web] [2024-09-30 23:01:25]     at async file:///workspace/.output/server/chunks/build/server.mjs:1916:93
[afleurist-web] [2024-09-30 23:01:25]     at async Object.callAsync (file:///workspace/.output/server/chunks/runtime.mjs:5809:16)
[afleurist-web] [2024-09-30 23:01:25]     at async applyPlugin (file:///workspace/.output/server/chunks/build/server.mjs:139:35)
[afleurist-web] [2024-09-30 23:01:25]     at async executePlugin (file:///workspace/.output/server/chunks/build/server.mjs:177:9)
[afleurist-web] [2024-09-30 23:01:25]     at async applyPlugins (file:///workspace/.output/server/chunks/build/server.mjs:191:5)
[afleurist-web] [2024-09-30 23:01:25]     at async createNuxtAppServer (file:///workspace/.output/server/chunks/build/server.mjs:2732:7)
[afleurist-web] [2024-09-30 23:01:25]     at async Object.renderToString (file:///workspace/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs:173:19) {
[afleurist-web] [2024-09-30 23:01:25]   [cause]: TypeError: Could not convert argument of type symbol to string.
[afleurist-web] [2024-09-30 23:01:25]       at node:internal/deps/undici/undici:12502:13
[afleurist-web] [2024-09-30 23:01:25]       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[afleurist-web] [2024-09-30 23:01:25] }
[afleurist-web] [2024-09-30 23:01:26] Unable to load user identity from API FetchError: [GET] "https://dev-api.afleurist.com/api/users/me": <no response> Could not convert argument of type symbol to string.
[afleurist-web] [2024-09-30 23:01:26]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[afleurist-web] [2024-09-30 23:01:26]     at async $fetch2 (file:///workspace/.output/server/chunks/runtime.mjs:3716:15)
[afleurist-web] [2024-09-30 23:01:26]     at async initialIdentityLoad (file:///workspace/.output/server/chunks/build/server.mjs:1889:20)
[afleurist-web] [2024-09-30 23:01:26]     at async file:///workspace/.output/server/chunks/build/server.mjs:1916:93
[afleurist-web] [2024-09-30 23:01:26]     at async Object.callAsync (file:///workspace/.output/server/chunks/runtime.mjs:5809:16)
[afleurist-web] [2024-09-30 23:01:26]     at async applyPlugin (file:///workspace/.output/server/chunks/build/server.mjs:139:35)
[afleurist-web] [2024-09-30 23:01:26]     at async executePlugin (file:///workspace/.output/server/chunks/build/server.mjs:177:9)
[afleurist-web] [2024-09-30 23:01:26]     at async applyPlugins (file:///workspace/.output/server/chunks/build/server.mjs:191:5)
[afleurist-web] [2024-09-30 23:01:26]     at async createNuxtAppServer (file:///workspace/.output/server/chunks/build/server.mjs:2732:7)
[afleurist-web] [2024-09-30 23:01:26]     at async Object.renderToString (file:///workspace/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs:173:19) {
[afleurist-web] [2024-09-30 23:01:26]   [cause]: TypeError: Could not convert argument of type symbol to string.
[afleurist-web] [2024-09-30 23:01:26]       at node:internal/deps/undici/undici:12502:13
[afleurist-web] [2024-09-30 23:01:26]       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[afleurist-web] [2024-09-30 23:01:26] }

It's my development environment that is giving me this error. My local environment works great using Docker. I'm also able to sign-in via cookies with Postman in my development environment, which leads me to believe I've got everything set up correctly on the API level.

I've turned off all the routeRules I'm using just in case, but I'm still having this issue.

manchenkoff commented 3 weeks ago

I have just published new 0.4.15 version, please give it a try and let me know if it helps!

@ahoiroman @calebwaldner

ahoiroman commented 3 weeks ago

Alright.

The error is gone, but now I can't login, as I am getting an csrf-token mismatch.

I will investigate on this and come back to you as soon as I am sure that the problem is not based on a misconfiguration.

manchenkoff commented 3 weeks ago

Alright.

The error is gone, but now I can't login, as I am getting an csrf-token mismatch.

I will investigate on this and come back to you as soon as I am sure that the problem is not based on a misconfiguration.

In this release, I also added more logs, so you can try to switch logLevel to 4 to see debug messages or to 5 to see traces with complete request/response headers output. So, you should see the proper headers I mentioned previously.

ahoiroman commented 3 weeks ago

Again, thanks thousand times for your time and efforts.

I created a new issue here: https://github.com/manchenkoff/nuxt-auth-sanctum/issues/188

calebwaldner commented 3 weeks ago

Thanks for the quick reply and updates! I won't be able to test this till later today or tomorrow, I'll post an update then.

calebwaldner commented 3 weeks ago

Everything is working as expected after updating to v0.4.18. Thanks!