You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a site hosted on netlify and am using Nuxt 3. I was using the npm run generate command and I had in my nuxt file structure a netlify directory with edge functions (/netlify/edge-functions/foo.js).
I wanted to move away from SSG and start using SWR and leveraging the cache so rather than pre-rendering the entire site I set the netlify build command to npm run build. This requires the nitro config to be set a bit differently as documented in the netlify docs for using nuxt on netlify:
Nuxt 3 introduces new rendering options, such as server-side rendering (SSR). SSR is supported when you deploy Nuxt 3 to Netlify, but requires configuration when you use Edge Functions.
It seems this is happening because the nuxt pages directory is scanned and the pages are being served. If there would be a page bar.vue (/pages/bar.vue)
It appears that this page is being served from the edge which is pretty cool. But how can I set this up that my edge functions in /netlify/edge-functions/foo.js still work?
Another interesting thing is that when the build command runs on netlify, it shows that the edge functions are bundled. When the nitro netlify_edge preset is used though, trying to fetch foo fails since it isn‘t a page. Also running netlify dev works as I would expect, so something here must be happening with the nitro output that I don't understand.
I can see here in the source code what is going on, but I don't get why I can't hit the edge function as an endpoint.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a site hosted on netlify and am using Nuxt 3. I was using the
npm run generate
command and I had in my nuxt file structure anetlify
directory with edge functions (/netlify/edge-functions/foo.js
).I wanted to move away from SSG and start using SWR and leveraging the cache so rather than pre-rendering the entire site I set the netlify build command to
npm run build
. This requires the nitro config to be set a bit differently as documented in the netlify docs for using nuxt on netlify:In my
nuxt.config.ts
file I set this upNow when I run this edge function from
/netlify/edge-functions/foo.js
I get an error
It seems this is happening because the nuxt
pages
directory is scanned and the pages are being served. If there would be a pagebar.vue
(/pages/bar.vue
)It appears that this page is being served from the edge which is pretty cool. But how can I set this up that my edge functions in
/netlify/edge-functions/foo.js
still work?Another interesting thing is that when the build command runs on netlify, it shows that the edge functions are bundled. When the nitro
netlify_edge
preset is used though, trying to fetch foo fails since it isn‘t a page. Also runningnetlify dev
works as I would expect, so something here must be happening with the nitro output that I don't understand.I can see here in the source code what is going on, but I don't get why I can't hit the edge function as an endpoint.
Beta Was this translation helpful? Give feedback.
All reactions