Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] When using https and the user is authenticated when refresh it gets log out #275

Open
ezekel opened this issue Dec 30, 2024 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@ezekel
Copy link

ezekel commented Dec 30, 2024

Hi @manchenkoff,

I noticed an issue when using HTTPS with both Laravel and Nuxt, and setting ssr: true in my nuxt.config. After authenticating, if I refresh the Nuxt app, it redirects me to the login page. Additionally, if I try to directly access the URL https://larabells.local/dashboard in the browser, it also redirects me to the login page.

Note:

Disabling the ssr works fine

I am using frankenphp laravell 11 and nuxt3 and caddy and docker

.env

NUXT_PUBLIC_SANCTUM_BASE_URL=https://api.larabells.local

nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config

export default defineNuxtConfig({

   compatibilityDate: '2024-04-03',
   devtools: {enabled: true},
   ssr: true,
   devServer: {
       host: 'larabells.local',
       port: 4000,
       //https:true

   },
    // vite: {
    //     server: {
    //        hmr: {
    //             protocol: 'wss',
    //             clientPort: 443,
    //         },
    //    },
    // },
   modules: [
       "@nuxtjs/tailwindcss",
       "shadcn-nuxt",
       '@nuxtjs/tailwindcss',
       '@nuxtjs/color-mode',
       "nuxt-auth-sanctum"
   ],
   colorMode: {
       classSuffix: ''
   },
   shadcn: {
       /**
        * Prefix for all the imported component
        */
       prefix: '',
       /**
        * Directory that the component lives in.
        * @default "./components/ui"
        */
       componentDir: './components/ui'
   },
   sanctum: {
       baseUrl:  process.env.NUXT_PUBLIC_API_URL, // Laravel API
       mode: 'cookie',

       /*endpoints: {
           user: '/api/user',
       },*/
       redirect: {
           onGuestOnly: '/dashboard',
           onLogin:'/dashboard',
           onLogout: '/login',
       },
   },
})

login.vue

<script setup lang="ts">
definePageMeta({
 /*layout: 'minimal',*/
 middleware: ['sanctum:guest'],
})


</script>

<template>
 <AuthLoginForm />
</template>

<style scoped>

</style>

dashboard.vue

<script setup lang="ts">
import { Button } from '~/components/ui/button'


definePageMeta({
  layout: 'auth',
  middleware: ['sanctum:auth','sanctum-verified'],
})

  <Button type="submit" class="mt-5" @click="books">
    Books
  </Button>
  

see my video

nuxt-auth-1.mp4

Thank you in advance

@ezekel ezekel added the bug Something isn't working label Dec 30, 2024
@manchenkoff
Copy link
Owner

Hey @ezekel, do you have different URL for Laravel which is accessible by your Nuxt server app?

Usually it happens if SSR and CSR call different URLs and thus cookies are not available. For more details, you can also change the sanctum module log level to 5 (you can find it in the module docs) and attach output here, it should show why your user gets unauthenticated on page refresh.

@ezekel
Copy link
Author

ezekel commented Dec 30, 2024

Hi @manchenkoff ,

can you show me where to edit the sanctum module to level 5 ?

Usually it happens if SSR and CSR call different URLs and thus cookies are not available.

but why if disable ssr it will works fine ? if I refresh it will not redirect to login page if I disable the ssr.

Thank you in advance.

@ezekel ezekel closed this as completed Dec 30, 2024
@ezekel ezekel reopened this Dec 30, 2024
@manchenkoff
Copy link
Owner

can you show me where to edit the sanctum module to level 5 ?

Please, check this link - https://manchenkoff.gitbook.io/nuxt-auth-sanctum/advanced/logging

but why if disable ssr it will works fine ? if I refresh it will not redirect to login page if I disable the ssr.

The difference between SSR and CSR is that your Laravel API is being called from different hosts, which can cause CORS issues and may not be supported by the Laravel app if the SSR host is not included in stateful domain list.

You can check more details here - https://manchenkoff.gitbook.io/nuxt-auth-sanctum/usage/cookie-authentication

@ezekel
Copy link
Author

ezekel commented Dec 31, 2024

Hi @manchenkoff

I don't know if I get the correct using logLevel

nuxt.config.ts

sanctum: {
        baseUrl:  process.env.NUXT_PUBLIC_API_URL, // Laravel API
        mode: 'cookie',

        endpoints: {
            user: '/api/user',
        },
        redirect: {
            onGuestOnly: '/dashboard',
            onLogin:'/dashboard',
            onLogout: '/login',
        },
        logLevel: 5,
    },
here is the log of my docker node when I refresh the page
  [nuxt-auth-sanctum:ssr] ⚙ Fetching user identity on plugin initialization
2024-12-31T07:30:03.998732700Z [nuxt-auth-sanctum:ssr] ⚙ [request] added default headers [ 'Accept' ]
2024-12-31T07:30:03.998751200Z [nuxt-auth-sanctum:ssr] ⚙ [request] added client headers to server request [ 'Referer', 'Origin', 'Cookie', 'User-Agent' ]
2024-12-31T07:30:03.998753800Z [nuxt-auth-sanctum:ssr] → Request headers for "/api/user" { accept: 'application/json',
2024-12-31T07:30:03.998755800Z   cookie:
2024-12-31T07:30:03.998830700Z    'XSRF-TOKEN=eyJpdiI6IjUxNFBGNjQ5NktZdUVsS05xR3BtR0E9PSIsInZhbHVlIjoiYVhZTVRNV0JaWEY5eWtKRDNqUklnSXBCUzJwaHp6U1gwSjRISFZnS1BwR3FqWEZmUHNHTkVvL2F3T1V5VmZXNXY3a3k5eUR1QTU3SjJQQ3NROWlIdlBrdFpMdUdLNWlPUkJmWmFkMEZrOTBXNjEwY2UrY2hHK09wWlM1MzE5V1ciLCJtYWMiOiIyZGMxNzE3ZGFiODE3ZWEwN2VlYzM2YWU5NWE4YjI4YzJlZmFjYzBhZjk3YzgyNWUwMjVkNWIyZjE1ZWIwNWUxIiwidGFnIjoiIn0%3D; laravel_session=eyJpdiI6Ii8vUFBzWHFjeGcrYWtqMnFyRWJuVlE9PSIsInZhbHVlIjoiUVFhTFJMYVA5UTkvQ2NCdDBNenhpakVBSzRWTWJoYUZDVm1XZ1ovdEN2cWxNL0d0VWVQZzRRb0dCR05hM2hWSE9kbHJkWmlFSUhWUzFZR2tlOVhpQi9ldTZnNitaQ0xmV2pIWEVMTHZIVEUyc05iWHJVZVZyRTJaZjVoYTFkRDciLCJtYWMiOiIyNzlkMzY3YmQzOGM1ZDU5MjczYTExOGMyZTRhMjVmZjVkYWM4ZjkyMGM5M2ZjOWJkMWNmNDA5MDlmMjY4ZWVmIiwidGFnIjoiIn0%3D; remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6IjE0bkdIQjVIVlBtSXY2dTZIVTdlT2c9PSIsInZhbHVlIjoibGVBd2kyWldlYXJyeml3Rlhja2h4MFBlNDU1dmdUN2hOcFBUTUhYcFRRaUkxWGRhNFU3NXVWTmhQc0pCUkEydERtM0d3U29iMWZKRVg0cGNOTWF4TzlMbE8wcERQRnR3UFpYSCt4bGtselVZay9Id0ptczhsZmlZZlR3TFE4U1d3c0FGd09JYUU3ampWMElFUXJQdkJRLzJMbmI4TUs0U3RYVjhIQnBLWnBaRFF6SWQ5Z211aXhabnR3NFZnMms4Y2FxYzZ0dzJmaU9JMjVwNkdrK2tycVNxVDl6a2RSeEhVY2Ntc0RiQjhucz0iLCJtYWMiOiI5ZWRmMWJjNWU2NTA0YTE0MWFhNDA0Y2VhN2UyYzlhYmM3ZWYxMGQzN2E5ZTE0NmZjZTc5MjAyNDk1MmVjODBjIiwidGFnIjoiIn0%3D',
2024-12-31T07:30:03.998852400Z   origin: 'https://larabells.local',
2024-12-31T07:30:03.998855700Z   referer: 'https://larabells.local',
2024-12-31T07:30:03.998858000Z   'user-agent':
2024-12-31T07:30:03.998860500Z    'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0' }
2024-12-31T07:30:03.998863200Z     at FancyReporter.formatLogObj (node_modules/consola/dist/shared/consola.DC9Xh_QO.mjs:602:20)
2024-12-31T07:30:03.998865600Z     at FancyReporter.log (node_modules/consola/dist/shared/consola.Cs5FdtHD.mjs:61:23)
2024-12-31T07:30:03.998868200Z     at Consola._log (node_modules/consola/dist/core.mjs:483:16)
2024-12-31T07:30:03.998871400Z     at resolveLog (node_modules/consola/dist/core.mjs:451:14)
2024-12-31T07:30:03.998873900Z     at Consola._logFn (node_modules/consola/dist/core.mjs:479:5)
2024-12-31T07:30:03.998876500Z     at Consola.trace (node_modules/consola/dist/core.mjs:408:19)
2024-12-31T07:30:03.998879000Z     at onRequest (node_modules/nuxt-auth-sanctum/dist/runtime/httpFactory.js:59:14)
2024-12-31T07:30:03.998881600Z     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2024-12-31T07:30:03.998884200Z     at async callHooks (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:134:7)
2024-12-31T07:30:03.998886600Z     at async $fetchRaw2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:207:7)
2024-12-31T07:30:04.000504200Z 
2024-12-31T07:30:04.000547100Z [nuxt-auth-sanctum:ssr]  ERROR  Unable to load user identity from API [GET] "https://api.larabells.local/api/user": <no response> fetch failed
2024-12-31T07:30:04.000553300Z 
2024-12-31T07:30:04.000577500Z     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2024-12-31T07:30:04.000580400Z     at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:316:15)
2024-12-31T07:30:04.000582800Z     at async initialIdentityLoad (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:42:20)
2024-12-31T07:30:04.000585200Z     at async setup (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:70:119)
2024-12-31T07:30:04.000588200Z     at async Object.callAsync (node_modules/unctx/dist/index.mjs:72:16)
2024-12-31T07:30:04.000590600Z     at async applyPlugin (node_modules/nuxt/dist/app/nuxt.js:142:25)
2024-12-31T07:30:04.000593100Z     at async executePlugin (node_modules/nuxt/dist/app/nuxt.js:179:9)
2024-12-31T07:30:04.000619200Z     at async applyPlugins (node_modules/nuxt/dist/app/nuxt.js:193:5)
2024-12-31T07:30:04.000622300Z     at async createNuxtAppServer (node_modules/nuxt/dist/app/entry.js:15:7)
2024-12-31T07:30:04.000625500Z     at async default (node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:34:18)
2024-12-31T07:30:04.000641200Z 
2024-12-31T07:30:04.000642900Z   [cause]: fetch failed
2024-12-31T07:30:04.000644700Z 
2024-12-31T07:30:04.000646400Z       at node:internal/deps/undici/undici:13185:13
2024-12-31T07:30:04.000648100Z       at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2024-12-31T07:30:04.000649900Z       at async $fetchRaw2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:258:26)
2024-12-31T07:30:04.000651900Z       at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:316:15)
2024-12-31T07:30:04.000653700Z       at async initialIdentityLoad (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:42:20)
2024-12-31T07:30:04.000655500Z       at async setup (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:70:119)
2024-12-31T07:30:04.000657200Z       at async Object.callAsync (node_modules/unctx/dist/index.mjs:72:16)
2024-12-31T07:30:04.000659000Z       at async applyPlugin (node_modules/nuxt/dist/app/nuxt.js:142:25)
2024-12-31T07:30:04.000660900Z       at async executePlugin (node_modules/nuxt/dist/app/nuxt.js:179:9)
2024-12-31T07:30:04.000662600Z       at async applyPlugins (node_modules/nuxt/dist/app/nuxt.js:193:5)
2024-12-31T07:30:04.000664300Z 
2024-12-31T07:30:04.000666000Z     [cause]: connect ECONNREFUSED 172.18.0.4:443
2024-12-31T07:30:04.000667700Z 
2024-12-31T07:30:04.000669300Z         at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1611:16)
2024-12-31T07:30:04.000671000Z         at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)
2024-12-31T07:30:04.000672800Z 
2024-12-31T07:30:04.045345200Z [nuxt-auth-sanctum:ssr] ⚙ Fetching user identity on plugin initialization
2024-12-31T07:30:04.047588000Z [nuxt-auth-sanctum:ssr] ⚙ [request] added default headers [ 'Accept' ]
2024-12-31T07:30:04.047629900Z [nuxt-auth-sanctum:ssr] ⚙ [request] added client headers to server request [ 'Referer', 'Origin', 'Cookie', 'User-Agent' ]
2024-12-31T07:30:04.047633200Z [nuxt-auth-sanctum:ssr] → Request headers for "/api/user" { accept: 'application/json',
2024-12-31T07:30:04.047645100Z   cookie:
2024-12-31T07:30:04.047649000Z    'XSRF-TOKEN=eyJpdiI6IjUxNFBGNjQ5NktZdUVsS05xR3BtR0E9PSIsInZhbHVlIjoiYVhZTVRNV0JaWEY5eWtKRDNqUklnSXBCUzJwaHp6U1gwSjRISFZnS1BwR3FqWEZmUHNHTkVvL2F3T1V5VmZXNXY3a3k5eUR1QTU3SjJQQ3NROWlIdlBrdFpMdUdLNWlPUkJmWmFkMEZrOTBXNjEwY2UrY2hHK09wWlM1MzE5V1ciLCJtYWMiOiIyZGMxNzE3ZGFiODE3ZWEwN2VlYzM2YWU5NWE4YjI4YzJlZmFjYzBhZjk3YzgyNWUwMjVkNWIyZjE1ZWIwNWUxIiwidGFnIjoiIn0%3D; laravel_session=eyJpdiI6Ii8vUFBzWHFjeGcrYWtqMnFyRWJuVlE9PSIsInZhbHVlIjoiUVFhTFJMYVA5UTkvQ2NCdDBNenhpakVBSzRWTWJoYUZDVm1XZ1ovdEN2cWxNL0d0VWVQZzRRb0dCR05hM2hWSE9kbHJkWmlFSUhWUzFZR2tlOVhpQi9ldTZnNitaQ0xmV2pIWEVMTHZIVEUyc05iWHJVZVZyRTJaZjVoYTFkRDciLCJtYWMiOiIyNzlkMzY3YmQzOGM1ZDU5MjczYTExOGMyZTRhMjVmZjVkYWM4ZjkyMGM5M2ZjOWJkMWNmNDA5MDlmMjY4ZWVmIiwidGFnIjoiIn0%3D; remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6IjE0bkdIQjVIVlBtSXY2dTZIVTdlT2c9PSIsInZhbHVlIjoibGVBd2kyWldlYXJyeml3Rlhja2h4MFBlNDU1dmdUN2hOcFBUTUhYcFRRaUkxWGRhNFU3NXVWTmhQc0pCUkEydERtM0d3U29iMWZKRVg0cGNOTWF4TzlMbE8wcERQRnR3UFpYSCt4bGtselVZay9Id0ptczhsZmlZZlR3TFE4U1d3c0FGd09JYUU3ampWMElFUXJQdkJRLzJMbmI4TUs0U3RYVjhIQnBLWnBaRFF6SWQ5Z211aXhabnR3NFZnMms4Y2FxYzZ0dzJmaU9JMjVwNkdrK2tycVNxVDl6a2RSeEhVY2Ntc0RiQjhucz0iLCJtYWMiOiI5ZWRmMWJjNWU2NTA0YTE0MWFhNDA0Y2VhN2UyYzlhYmM3ZWYxMGQzN2E5ZTE0NmZjZTc5MjAyNDk1MmVjODBjIiwidGFnIjoiIn0%3D',
2024-12-31T07:30:04.047659100Z   origin: 'https://larabells.local',
2024-12-31T07:30:04.047661000Z   referer: 'https://larabells.local',
2024-12-31T07:30:04.047662800Z   'user-agent':
2024-12-31T07:30:04.047664600Z    'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0' }
2024-12-31T07:30:04.047666400Z     at FancyReporter.formatLogObj (node_modules/consola/dist/shared/consola.DC9Xh_QO.mjs:602:20)
2024-12-31T07:30:04.047668100Z     at FancyReporter.log (node_modules/consola/dist/shared/consola.Cs5FdtHD.mjs:61:23)
2024-12-31T07:30:04.047669900Z     at Consola._log (node_modules/consola/dist/core.mjs:483:16)
2024-12-31T07:30:04.047672700Z     at resolveLog (node_modules/consola/dist/core.mjs:451:14)
2024-12-31T07:30:04.047674400Z     at Consola._logFn (node_modules/consola/dist/core.mjs:479:5)
2024-12-31T07:30:04.047676200Z     at Consola.trace (node_modules/consola/dist/core.mjs:408:19)
2024-12-31T07:30:04.047677900Z     at onRequest (node_modules/nuxt-auth-sanctum/dist/runtime/httpFactory.js:59:14)
2024-12-31T07:30:04.047679700Z     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2024-12-31T07:30:04.047681500Z     at async callHooks (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:134:7)
2024-12-31T07:30:04.047683200Z     at async $fetchRaw2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:207:7)
2024-12-31T07:30:04.048850500Z 
2024-12-31T07:30:04.048885100Z [nuxt-auth-sanctum:ssr]  ERROR  Unable to load user identity from API [GET] "https://api.larabells.local/api/user": <no response> fetch failed
2024-12-31T07:30:04.048890100Z 
2024-12-31T07:30:04.048891900Z     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2024-12-31T07:30:04.048893700Z     at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:316:15)
2024-12-31T07:30:04.048895500Z     at async initialIdentityLoad (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:42:20)
2024-12-31T07:30:04.048897400Z     at async setup (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:70:119)
2024-12-31T07:30:04.048899100Z     at async Object.callAsync (node_modules/unctx/dist/index.mjs:72:16)
2024-12-31T07:30:04.048900800Z     at async applyPlugin (node_modules/nuxt/dist/app/nuxt.js:142:25)
2024-12-31T07:30:04.048902600Z     at async executePlugin (node_modules/nuxt/dist/app/nuxt.js:179:9)
2024-12-31T07:30:04.048904300Z     at async applyPlugins (node_modules/nuxt/dist/app/nuxt.js:193:5)
2024-12-31T07:30:04.048913000Z     at async createNuxtAppServer (node_modules/nuxt/dist/app/entry.js:15:7)
2024-12-31T07:30:04.048914900Z     at async default (node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:34:18)
2024-12-31T07:30:04.048916700Z 
2024-12-31T07:30:04.048918400Z   [cause]: fetch failed
2024-12-31T07:30:04.048920100Z 
2024-12-31T07:30:04.048921700Z       at node:internal/deps/undici/undici:13185:13
2024-12-31T07:30:04.048923400Z       at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2024-12-31T07:30:04.048925200Z       at async $fetchRaw2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:258:26)
2024-12-31T07:30:04.048926900Z       at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.03887fc3.mjs:316:15)
2024-12-31T07:30:04.048928700Z       at async initialIdentityLoad (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:42:20)
2024-12-31T07:30:04.048930500Z       at async setup (node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:70:119)
2024-12-31T07:30:04.048932300Z       at async Object.callAsync (node_modules/unctx/dist/index.mjs:72:16)
2024-12-31T07:30:04.048934000Z       at async applyPlugin (node_modules/nuxt/dist/app/nuxt.js:142:25)
2024-12-31T07:30:04.048935800Z       at async executePlugin (node_modules/nuxt/dist/app/nuxt.js:179:9)
2024-12-31T07:30:04.048937500Z       at async applyPlugins (node_modules/nuxt/dist/app/nuxt.js:193:5)
2024-12-31T07:30:04.048939200Z 
2024-12-31T07:30:04.048940900Z     [cause]: connect ECONNREFUSED 172.18.0.4:443
2024-12-31T07:30:04.048942600Z 
2024-12-31T07:30:04.048944200Z         at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1611:16)
2024-12-31T07:30:04.048946000Z         at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)
2024-12-31T07:30:04.048947800Z 

    APP_URL=https://api.larabells.local
FRONTEND_URL=https://larabells.local
SANCTUM_STATEFUL_DOMAINS=larabells.local
SESSION_DOMAIN=.larabells.local

I tried also to include the api to the stateful domains but no luck

SANCTUM_STATEFUL_DOMAINS=larabells.local,api.larabells.local

I also have middleware

middleware/sanctum_verified.ts

export default defineNuxtRouteMiddleware(() => {
  const sanctumConfig = useSanctumConfig()

  const { isAuthenticated, user } = useSanctumAuth()

  if (!isAuthenticated.value) {
    if (sanctumConfig.redirect.onAuthOnly === false) {
      return createError({
        statusCode: 409,
        message: 'You must verify your email to access this page',
        fatal: true,
      })
    }

    return navigateTo(sanctumConfig.redirect.onAuthOnly)
  }

  if (user.value?.email_verified_at !== null) {
    console.log("verified")
    return
  }

  return navigateTo('/verify-email')
})

@ezekel
Copy link
Author

ezekel commented Dec 31, 2024

I saw this it looks like same problem withe me ssr enable

#209

but I tried to put this to sanctum module it doesnt work

client: {
            initialRequest: true,
        }
    sanctum: {
        baseUrl:  process.env.NUXT_PUBLIC_API_URL, // Laravel API
        mode: 'cookie',

        endpoints: {
            user: '/api/user',
        },
        redirect: {
            onGuestOnly: '/dashboard',
            onLogin:'/dashboard',
            onLogout: '/login',
        },
        logLevel: 5,
        client: {
            initialRequest: true,
        }
    },

@manchenkoff
Copy link
Owner

2024-12-31T07:30:04.048885100Z [nuxt-auth-sanctum:ssr] ERROR Unable to load user identity from API [GET] "https://api.larabells.local/api/user": fetch failed

@ezekel, in your case, this is a problem. Your Laravel API is not reachable from the Nuxt SSR image, probably because your Docker container is named differently. It has nothing to do with the initialRequest config. If you have Laravel and Nuxt apps under the same network, you should name your Laravel container by the domain name as well, in your case - api.larabells.local should be fine.

I tried also to include the api to the stateful domains but no luck SANCTUM_STATEFUL_DOMAINS=larabells.local,api.larabells.local

This is unnecessary because api.* domain is not for frontend callers.

@manchenkoff manchenkoff added question Further information is requested and removed bug Something isn't working labels Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants