unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
6.13k stars 503 forks source link

public assets not working with `netlify-edge` preset #854

Closed issue-up[bot] closed 5 months ago

issue-up[bot] commented 1 year ago
   Forwarded from downstream issue: - https://github.com/nuxt/nuxt.js/issues/15303 by @mohsin

### Environment Nuxi 3.0.0-rc.12 RootDir: /Users/Mohsin/Work/Client/iMoz/Projects/iMoz Nuxt project info: (copied to clipboard) ------------------------------ - Operating System: `Darwin` - Node Version: `v16.13.2` - Nuxt Version: `3.0.0-rc.12` - Nitro Version: `0.6.0` - Package Manager: `yarn@1.22.10` - Builder: `vite` - User Config: `app`, `css`, `nitro`, `build` - Runtime Modules: `-` - Build Modules: `-` ### Reproduction 1. Deploy the blog to Netlify using [the main branch of the code](https://github.com/mohsin/iMoz-Web). 2. Ensure the Netlify deploy setting is set to use `yarn build` as the build command and `dist` as the publish folder. 3. Open browser and see the errors occur. ### Describe the bug I'm building a personal blog for myself using Nuxt 3 and [I'm getting issues](https://bright-wisp-26db17.netlify.app) that the CSS, JS, and image assets aren't loading due to `Failed to load resource: the server responded with a status of 404 (Not Found)` issue. I'm using the `netlify-edge` preset (as I hope to do some edge functions such as language switching based on geography down the line). When I run it using `yarn dev` it works on my machine but not using `ntl dev` or when I put it in Netlify to run. I can [get it to work](https://comforting-croquembouche-211780.netlify.app) by changing the build command to `yarn generate` on netlify but I believe that's static and not edge rendered. My blog is open-source so you can see the code and deploy [from here](https://github.com/mohsin/iMoz-Web). Would appreciate it if I get my issue resolved by telling me if I'm doing something wrong or if it's an issue with the framework since it's in RC, I hope it gets resolved (workaround would be appreciated). Thanks. Screenshot 2022-10-30 at 13 34 11 ### Additional context During my initial development, I did not get any such errors on deploying to Netlify until I added tailwind css. I'm thinking that since tailwind adds stylesheets it failed but idk. ### Logs ```shell 1:16:01 PM: build-image version: d7b3813f01c06610bc1723ff1b22446513ee7941 (focal) 1:16:01 PM: build-image tag: v4.14.3 1:16:01 PM: buildbot version: f2613f2234a773b4fab58b5a3c03c743fe78f9bf 1:16:01 PM: Fetching cached dependencies 1:16:02 PM: Starting to download cache of 282.4MB 1:16:02 PM: Finished downloading cache in 798.507396ms 1:16:02 PM: Starting to extract cache 1:16:04 PM: Finished extracting cache in 1.669377923s 1:16:04 PM: Finished fetching cache in 2.605631866s 1:16:04 PM: Starting to prepare the repo for build 1:16:04 PM: Preparing Git Reference refs/heads/main 1:16:04 PM: Parsing package.json dependencies 1:16:06 PM: Starting build script 1:16:06 PM: Installing dependencies 1:16:06 PM: Python version set to 2.7 1:16:06 PM: Started restoring cached node version 1:16:06 PM: Finished restoring cached node version 1:16:07 PM: v16.18.0 is already installed. 1:16:07 PM: Now using node v16.18.0 (npm v8.19.2) 1:16:07 PM: Enabling node corepack 1:16:07 PM: Started restoring cached build plugins 1:16:07 PM: Finished restoring cached build plugins 1:16:07 PM: Attempting ruby version 2.7.2, read from environment 1:16:08 PM: Using ruby version 2.7.2 1:16:08 PM: Using PHP version 8.0 1:16:08 PM: Started restoring cached yarn cache 1:16:09 PM: Finished restoring cached yarn cache 1:16:09 PM: No yarn workspaces detected 1:16:09 PM: Started restoring cached node modules 1:16:09 PM: Finished restoring cached node modules 1:16:09 PM: Installing NPM modules using Yarn version 1.22.19 1:16:10 PM: yarn install v1.22.19 1:16:10 PM: [1/4] Resolving packages... 1:16:10 PM: [2/4] Fetching packages... 1:16:10 PM: warning vscode-languageclient@7.0.0: The engine "vscode" appears to be invalid. 1:16:10 PM: [3/4] Linking dependencies... 1:16:11 PM: [4/4] Building fresh packages... 1:16:11 PM: success Saved lockfile. 1:16:11 PM: $ nuxt prepare 1:16:11 PM: [log] Nuxi 3.0.0-rc.12 1:16:12 PM: [success] Types generated in .nuxt 1:16:12 PM: Done in 2.40s. 1:16:12 PM: NPM modules installed using Yarn 1:16:12 PM: Started restoring cached go cache 1:16:12 PM: Finished restoring cached go cache 1:16:12 PM: Installing Go version 1.17 (requested 1.17) 1:16:16 PM: unset GOOS; 1:16:16 PM: unset GOARCH; 1:16:16 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64'; 1:16:16 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}"; 1:16:16 PM: go version >&2; 1:16:16 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env" 1:16:16 PM: go version go1.17 linux/amd64 1:16:16 PM: Installing missing commands 1:16:16 PM: Verify run directory 1:16:17 PM: ​ 1:16:17 PM: ──────────────────────────────────────────────────────────────── 1:16:17 PM: Netlify Build 1:16:17 PM: ──────────────────────────────────────────────────────────────── 1:16:17 PM: ​ 1:16:17 PM: ❯ Version 1:16:17 PM: @netlify/build 28.1.4 1:16:17 PM: ​ 1:16:17 PM: ❯ Flags 1:16:17 PM: baseRelDir: true 1:16:17 PM: buildId: 635e2b8723d0fd000907b1ae 1:16:17 PM: deployId: 635e2b8723d0fd000907b1b0 1:16:17 PM: ​ 1:16:17 PM: ❯ Current directory 1:16:17 PM: /opt/build/repo 1:16:17 PM: ​ 1:16:17 PM: ❯ Config file 1:16:17 PM: No config file was defined: using default values. 1:16:17 PM: ​ 1:16:17 PM: ❯ Context 1:16:17 PM: production 1:16:17 PM: ​ 1:16:17 PM: ──────────────────────────────────────────────────────────────── 1:16:17 PM: 1. Build command from Netlify app 1:16:17 PM: ──────────────────────────────────────────────────────────────── 1:16:17 PM: ​ 1:16:17 PM: $ yarn build 1:16:18 PM: yarn run v1.22.19 1:16:18 PM: $ nuxt build 1:16:18 PM: [log] Nuxi 3.0.0-rc.12 1:16:18 PM: [log] Nuxt 3.0.0-rc.12 with Nitro 0.6.0 1:16:21 PM: [info] Client built in 1636ms 1:16:21 PM: [info] Building server... 1:16:21 PM: [success] Server built in 614ms 1:16:21 PM: [success] [nitro] Generated public dist 1:16:21 PM: [info] [nitro] Building Nitro Server (preset: `netlify-edge`) 1:16:27 PM: [success] [nitro] Nitro server built 1:16:27 PM: └─ .netlify/edge-functions/server.js (326 kB) (103 kB gzip) 1:16:27 PM: Σ Total size: 326 kB (103 kB gzip) 1:16:27 PM: Done in 9.39s. 1:16:27 PM: ​ 1:16:27 PM: (build.command completed in 9.5s) 1:16:27 PM: ​ 1:16:27 PM: ──────────────────────────────────────────────────────────────── 1:16:27 PM: 2. Edge Functions bundling 1:16:27 PM: ──────────────────────────────────────────────────────────────── 1:16:27 PM: ​ 1:16:27 PM: Packaging Edge Functions from .netlify/edge-functions directory: 1:16:27 PM: - server 1:16:28 PM: ​ 1:16:28 PM: (Edge Functions bundling completed in 749ms) 1:16:28 PM: ​ 1:16:28 PM: Creating deploy upload records 1:16:28 PM: ──────────────────────────────────────────────────────────────── 1:16:28 PM: 3. Deploy site 1:16:28 PM: ──────────────────────────────────────────────────────────────── 1:16:28 PM: ​ 1:16:28 PM: Starting to deploy site from 'dist' 1:16:28 PM: Creating deploy tree 1:16:28 PM: 2 new files to upload 1:16:28 PM: 0 new functions to upload 1:16:28 PM: Starting post processing 1:16:28 PM: Site deploy was successfully initiated 1:16:28 PM: ​ 1:16:28 PM: (Deploy site completed in 285ms) 1:16:28 PM: Post processing - HTML 1:16:28 PM: ​ 1:16:28 PM: ──────────────────────────────────────────────────────────────── 1:16:28 PM: Netlify Build Complete 1:16:28 PM: ──────────────────────────────────────────────────────────────── 1:16:28 PM: Post processing - header rules 1:16:28 PM: ​ 1:16:28 PM: (Netlify Build completed in 10.6s) 1:16:28 PM: Caching artifacts 1:16:28 PM: Post processing - redirect rules 1:16:28 PM: Started saving node modules 1:16:28 PM: Finished saving node modules 1:16:28 PM: Started saving build plugins 1:16:29 PM: Post processing done 1:16:28 PM: Finished saving build plugins 1:16:28 PM: Started saving yarn cache 1:16:29 PM: Finished saving yarn cache 1:16:29 PM: Started saving pip cache 1:16:29 PM: Finished saving pip cache 1:16:29 PM: Started saving emacs cask dependencies 1:16:29 PM: Finished saving emacs cask dependencies 1:16:29 PM: Started saving maven dependencies 1:16:29 PM: Finished saving maven dependencies 1:16:29 PM: Started saving boot dependencies 1:16:29 PM: Finished saving boot dependencies 1:16:29 PM: Started saving rust rustup cache 1:16:29 PM: Finished saving rust rustup cache 1:16:29 PM: Started saving go dependencies 1:16:29 PM: Finished saving go dependencies 1:16:29 PM: Build script success 1:16:30 PM: Uploading Cache of size 282.6MB 1:16:32 PM: Site is live ✨ 1:16:32 PM: Finished processing build request in 31.090925529s ```
officialpiyush commented 1 year ago

Facing similar issue, are there any workaround or fixes for this yet?

Here are the errors in the console: image

flozero commented 1 year ago

Same problem but I don't see the cors personnally. this feature is not working for me too I have to come back to netlify preset thats is not priced the same :s

robokozo commented 1 year ago

Yeah I'm seeing the same. The normal netlify preset still works but I need ssr. Normally I'd use firebase but that preset is also not working :(

gabrielstuff commented 1 year ago

I confirm that I'm facing the same issue. Here is the project :

https://github.com/gabrielstuff/charts.tools

And the build command is as in the doc : NITRO_PRESET=netlify-edge npm run build

How can we help with that ?

Hebilicious commented 1 year ago

Hi @gabrielstuff, my personal way of debugging/improving presets is to create a new custom one based on the existing preset, and try to make the necessary changes on my custom preset. However the issue could be unrelated to the preset.

To help with maintainers, you can also provide a minimal reproduction issue with nitro (ie without nuxt) on stackblitz.

pi0 commented 5 months ago

considering issue is stalled, please consider opening new issue with fresh reproduction if experience similar issues 🙏🏼