Closed ezekel closed 3 months ago
Hey @ezekel, since you are not using localhost
for your URLs, make sure that your session domain is set properly (should be .larabells.local
. However, when you refresh the page, Nuxt tries to send a request to your API from SSR environment, so it might be the case that this domain is not reachable due to docker network or the request cookies are refused.
Please, provide the logs from your nuxt app with the details of SSR request.
For docker setup, also take a look at the following issues:
yes sorry I forgot to post, I have already this configuration in my .env
SESSION_DOMAIN=.larabells.local
I also have this in my etc
127.0.0.1 nuxtnew.larabells.local
Hi,
Please, provide the logs from your nuxt app with the details of SSR request.
how can I get the log in console browser ?
I also have this in my etc
127.0.0.1 nuxtnew.larabells.local
make sure that docker also can resolve this URL into proper localhost binding because by default Nuxt container can access Laravel API only by the container name (which we usually define in docker-compose.yml
).
how can I get the log in console browser ?
You should get logs not from browser, but from your Node instance which handles SSR mode. Since you mentioned that you are using Docker for Nuxt, logs will be available there either in a file or in console output, but it depends on your configuration.
Hi,
This is the error in my docker nuxt app when I refresh the dashboard then it redirect to login
2024-08-21 20:50:17 system
2024-08-21 20:50:05
2024-08-21 20:50:05 [nuxt-auth-sanctum:ssr] ERROR Unable to load user identity from API [GET] "https://larabells.local/api/user": <no response> fetch failed
2024-08-21 20:50:05
2024-08-21 20:50:05 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-08-21 20:50:05 at async $fetch2 (node_modules/ofetch/dist/shared/ofetch.37386b05.mjs:268:15)
2024-08-21 20:50:05 at async node_modules/nuxt-auth-sanctum/dist/runtime/plugin.js:58:120
2024-08-21 20:50:05 at async Object.callAsync (node_modules/unctx/dist/index.mjs:72:16)
2024-08-21 20:50:05 at async applyPlugin (node_modules/nuxt/dist/app/nuxt.js:144:25)
2024-08-21 20:50:05 at async executePlugin (node_modules/nuxt/dist/app/nuxt.js:181:9)
2024-08-21 20:50:05 at async Module.applyPlugins (node_modules/nuxt/dist/app/nuxt.js:195:5)
2024-08-21 20:50:05 at async createNuxtAppServer (node_modules/nuxt/dist/app/entry.js:23:7)
2024-08-21 20:50:05 at async default (node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:34:18)
2024-08-21 20:50:05 at async Object.renderToString (node_modules/vue-bundle-renderer/dist/runtime.mjs:173:19)
2024-08-21 20:50:05
2024-08-21 20:50:05
2024-08-21 20:50:05 WARN [Vue Router warn]: No match found for location with path "/installHook.js.map"
2024-08-21 20:50:05
2024-08-21 20:50:05
2024-08-21 20:50:05 [nuxt-auth-sanctum:ssr] ERROR Unable to load user identity from API [GET] "https://larabells.local/api/user": <no response> fetch failed
@ezekel thanks for providing the error. As I said before, your problem is that Laravel container is not visible from your Nuxt container as stated in the error - [GET] "https://larabells.local/api/user": <no response> fetch failed
. Please, either check all the issues I mentioned previously (about how to configure 2 docker containers to work with each other) or disable SSR if you cannot do that for some reason.
Ok thank you I will be back
Hi
I just disable the SSR for now and it works like a charm
But I will just continue checking above on how to get work if enabling the SSR, although I have also the same network both the backend and my nuxt but no luck.
Thank you
Sure thing @ezekel, you can tackle it later but keep in mind that the problem is not the difference between networks, it is about dns resolving since container does not know about the domain linked to the other container, only its name. I usually name my containers like that:
api.playground.test
playground.test
In this case, if you call Laravel API from Nuxt SSR by domain name api.playground.test
it will be resolved into containers name api.playground.test
which will be resolved by docker network.
Hi @manchenkoff
I got it working with SSR enabled. I need to use http not https both frontend and backend in local development.
Thank you
Hi, I was able to successfully log in and it redirects me to the dashboard however when I refresh the page, I will get back to my login page, then If I manually type /dashboard to the URL keeps me redirected to login page even though I am authenticated.
My backend is Laravel 11 + octane using Frankenphp docker image
URL of my backend
https://larabells.local
.env of my backend
APP_URL=https://larabells.local FRONTEND_URL=https://nuxtnew.larabells.local:4000 SANCTUM_STATEFUL_DOMAINS=nuxtnew.larabells.local:4000 //commenting out and commenting in the issue still persist
and my frontend using docker also
https://nuxtnew.larabells.local:4000
in my nuxt app, I have .env
nuxtconfig
pages/dasbhoard.vue
pages/login.vue
pages/about.vue
package.json