nuxt-nhost
nuxt-nhost copied to clipboard
Cannot access datas in production
Cannot access Nhost datas in production on Netlify
Error messages :
In production, in the browser console, have :
- 404 POST error :
https://PRODUCTION_URL/api/_nhost/session
Tests carried out
- With Nuxt 2 and Nhost JS SDK is working
- With Nuxt 3 and Nhost JS SDK is working
Solution ?
I think the problem comes from that we recover the URL of the site (front-end) and not from the API. Maybe expecting : POST https://API_URL/api/_nhost/session ?
Is working with local build but no longer works in production.
Technos / versions / config :
- Nuxt 3 : 3.0.0-rc.8
- ssr : false
- nuxt-nhost : ^1.1.0
Could it be related to ssr: false
? If you generate a static build, /api/_nhost/session
won't be included. This route is part of the SSR build and persists the auth session, so you can reload the page without losing it (in the SSR context).
Mmh okay... I'm not yet completely comfortable with the SSR... What would be the solution? To pass SSR in True? What will it change?
I've test with SRR : true
but I've the same error...
Are you using the netlify-edge
or netlify
nitro preset? I think you need the edge one for SSR. If you remove the nitro preset from the config and simply run yarn build
and yarn preview
, does it work?
For me, it currently works fine in dev and the NodeJS & Cloudflare Worker prod build.
I will try my build on Netlify this week to find the problem.
Mmh... I don't no if I used netlify-edge
or nitro
but I don't have change Netlify base configuration (except build & domain)
Thanks for your test build!
I will try my build on Netlify this week to find the problem.
Hi! Were you able to test to find the problem ?
I have a solution! I've update Nuxt to 3.0.0-rc.9 (but I don't no if is that) I've build my app in CSR (and not static like before)
Now is working BUT the session is broken when I refresh the page... Have you a solution?
Have you had a look at #2? This should be the solution, at least for now.