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
When using a mono repository setup and Netlify presets for nitro some strange things happen:
There is a phantom dir that gets created under the app directory when using netlify-cli to preview the build process. For example within the reproduction link provided, "app_dir" which is a full nuxt directory will see {{MONO_REPO_ROOT}}/app_dir/app_dir/.netlify/functions-internal created within the existing {{MONO_REPO_ROOT}}/app_dir instead of inside the correct {{MONO_REPO_ROOT}}/app_dir/.netlify folder that already exists in the project. Even though the end result of the build outputs a server directory in the correct {{MONO_REPO_ROOT}}/app_dir/.netlify/functions-internal/server directory
Nuxt outputs a _redirect into the dist directory for netlify use in deployment. When a simple deployment prerenders some pages with route rules and also using the sitemap seo module the redirects for sitemap instruct netlify with the following:
maybe I'm dumb and .netlfiy/builders/server is a virtual route but if netlify only sees static files at the moment there is no serverless functions deployed so this is failing with 404. Attempted to change NITRO_PRESET from "netlify" to "netlify-builder" and this makes no difference in the outcomes mentioned in this issue. Looking at https://github.dev/unjs/nitro/blob/main/src/presets/netlify.ts it seems this may default to make certain assumptions here that don't reflect the instance configuration. (Again this may be my mistake which I will gladly be corrected to get things working 😜)
Additional context
The netlify command is run from the mono_repo root ntl serve to test the build and review config of what netlify will serve on the platform. Currently the demo has only static files to deploy but would in theory add dynamic things in the future (this may change the output with server routes to use "swr" settings to produce dynamic blog pages for example.
# This lives in the app of a single deployment -- in theory there would me multiple projects with a top level "layers" shared between nuxt projects in the mono repo
[build]
base = "app_dir/"command = "pnpm build"publish = "dist/"
Logs
✔ Server built in 13560ms 11:55:22 AM
ℹ Initializing prerenderer nitro 11:55:22 AM
ℹ Prerendering 3 routes nitro 11:55:29 AM
├─ /api/_content/cache.1714578893919.json (192ms) nitro 11:55:29 AM
├─ /api/_content/query/cdzJXZdsvf.1714578893919.json (6ms) nitro 11:55:29 AM
├─ / (440ms) nitro 11:55:29 AM
├─ /_payload.json (2ms) nitro 11:55:29 AM
ℹ Prerendered 6 routes in 13.385 seconds nitro 11:55:35 AM
[nitro] Nitro now uses `isr` option to configure ISR behavior on Netlify. Backwards-compatible support for`static` and `swr` support with Builder Functions will be removedin the future versions. Set `future.nativeSWR: true` nitro config
disable this warning.
✔ Generated public dist nitro 11:55:36 AM
ℹ Building Nuxt Nitro server (preset: netlify-builder) nitro 11:55:36 AM
✔ Nuxt Nitro server built nitro 11:55:46 AM
├─ .netlify/functions-internal/server/chunks/_/empty.mjs (126 B) (124 B gzip)
├─ .netlify/functions-internal/server/chunks/_/error-500.mjs (5.05 kB) (2.09 kB gzip)
├─ .netlify/functions-internal/server/chunks/_/node.mjs (142 B) (132 B gzip)
# ... etc
Σ Total size: 44.1 MB (17.4 MB gzip)
(build.command completed in 58s)
Functions bundling
────────────────────────────────────────────────────────────────
(Functions bundling completed in 1ms)
Save deploy artifacts
────────────────────────────────────────────────────────────────
(Save deploy artifacts completed in 1ms)
Netlify Build Complete
────────────────────────────────────────────────────────────────
(Netlify Build completed in 58s)
◈ Static server listening to 3999
┌─────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:8888 │
│ │
└─────────────────────────────────────────────────┘
◈ Redirecting /sitemap.xml to /sitemap_index.xml
◈ Rewrote URL to /.netlify/builders/server # <-- navigating to /sitemap which gets 404
The text was updated successfully, but these errors were encountered:
@danielroe I'm not sure its possible to reproduce as pure nitro, only because the current configuration state for the project which I have causing this does not use any ssr yet (at least to my understanding -- there is no server dir). Unless one of the modules is bootstraping behind the scenes. The seo module portion is where I think I'm hung up and may be the issue. I'm just noticing that it won't output a static sitemap and infers that a netlify function will resolve it (which is what the produced _redirects is telling netlify).
I can and will open this on the nitro side though and link back to this.
Environment
Reproduction
This will not reproduce in a stackblitz env due to wasm but there is a repo with the project to clone and test.
https://github.com/jbool24/nuxt-netlify-deploy
Describe the bug
When using a mono repository setup and Netlify presets for nitro some strange things happen:
{{MONO_REPO_ROOT}}/app_dir/app_dir/.netlify/functions-internal
created within the existing{{MONO_REPO_ROOT}}/app_dir
instead of inside the correct{{MONO_REPO_ROOT}}/app_dir/.netlify
folder that already exists in the project. Even though the end result of the build outputs aserver
directory in the correct{{MONO_REPO_ROOT}}/app_dir/.netlify/functions-internal/server
directory_redirect
into thedist
directory for netlify use in deployment. When a simple deployment prerenders some pages with route rules and also using the sitemap seo module the redirects for sitemap instruct netlify with the following:maybe I'm dumb and
.netlfiy/builders/server
is a virtual route but if netlify only sees static files at the moment there is no serverless functions deployed so this is failing with 404. Attempted to changeNITRO_PRESET
from "netlify" to "netlify-builder" and this makes no difference in the outcomes mentioned in this issue. Looking athttps://github.dev/unjs/nitro/blob/main/src/presets/netlify.ts
it seems this may default to make certain assumptions here that don't reflect the instance configuration. (Again this may be my mistake which I will gladly be corrected to get things working 😜)Additional context
The netlify command is run from the mono_repo root
ntl serve
to test the build and review config of what netlify will serve on the platform. Currently the demo has only static files to deploy but would in theory add dynamic things in the future (this may change the output with server routes to use "swr" settings to produce dynamic blog pages for example.Logs
The text was updated successfully, but these errors were encountered: