Skip to content

Production build fails to serve PWA assets (manifest.webmanifest, icons) on Nuxt 4 with node-server preset #228

Description

@ecanquiz

Description:

When building a Nuxt 4 application with @vite-pwa/nuxt, the PWA assets (manifest.webmanifest, icons, favicon.ico, etc.) are correctly generated and placed in .output/public/. However, when running the production server with node .output/server/index.mjs, Nitro looks for these assets in .output/server/chunks/public/ instead, causing 404 errors.

Steps to Reproduce

  1. Create a new Nuxt 4 project
  2. Install and configure @vite-pwa/nuxt:
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@vite-pwa/nuxt'],
  pwa: {
    registerType: 'autoUpdate',
    manifest: {
      name: 'Test App',
      short_name: 'Test',
      // ... manifest config
    }
  }
})
  1. Generate PWA assets (icons, manifest)
  2. Run npm run build
  3. Run production server: node .output/server/index.mjs
  4. Try to access /manifest.webmanifest or /favicon.ico

Expected Behavior

The PWA assets should be served correctly from the production server without any manual intervention.
Actual Behavior

The server returns a 500/404 error with:

H3Error: ENOENT: no such file or directory, open '/path/to/.output/server/chunks/public/manifest.webmanifest'

Environment

  • Nuxt version: 4.x (latest)
  • @vite-pwa/nuxt version: latest (0.9.0)
  • Nitro preset: node-server (default)
  • Node.js version: v24.16.0
  • Package manager: npm

Additional Context

The assets are correctly generated in .output/public/:

$ ls .output/public/
manifest.webmanifest  favicon.ico  pwa-64x64.png  pwa-192x192.png  pwa-512x512.png  maskable-icon-512x512.png  apple-touch-icon-180x180.png

However, the production server expects them in .output/server/chunks/public/.

Temporary Workaround

After building, manually copy the assets:

mkdir -p .output/server/chunks/public && cp -r .output/public/* .output/server/chunks/public/

Or add to package.json:

{
  "scripts": {
    "build": "nuxt build && mkdir -p .output/server/chunks/public && cp -r .output/public/* .output/server/chunks/public/"
  }
}

Related Issues / References

Possible Root Cause

The @vite-pwa/nuxt module writes assets to .output/public/, but when using the node-server preset in Nitro (default for Nuxt 4), the server expects static assets in .output/server/chunks/public/. This path mismatch breaks the PWA installation capability in production.

Suggested Fix

The module should detect the Nitro preset and write assets to the appropriate location, or Nitro should be configured to serve static assets from .output/public/ in all presets.

Labels

  • #bug
  • #production
  • #nuxt4
  • #nitro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions