Skip to content

[bug] V2 Next.js config assetPrefix breaks hot reload feature #9804

Closed
@mattma

Description

@mattma

Describe the bug

Following the Next.js integration Doc, step 3 contains the configuration below. Next.js hot reload feature won't work properly.

  // Configure assetPrefix or else the server won't properly resolve your assets.
  assetPrefix: isProd ? null : `http://${internalHost}:3000`,

I can even reproduce the issue by running Next.js app only in the browser, or running in desktop app by tauri dev. The terminal process will report the compiled status when the file changes have been made, but no hot reload in the browser or in the native desktop simulator.

By comment out the line assetPrefix, hot reload works as expected but it will break the feature the server won't properly resolve your assets..

Reproduction

  1. Follow the create tauri app guide
  2. Remove the Vite app, and replaced with fresh generated Next.js app by following guide

Expected behavior

  // Configure assetPrefix or else the server won't properly resolve your assets.
  assetPrefix: isProd ? null : `http://${internalHost}:3000`,

The next.js integration guide, with assetPrefix in place, next.js hot reload on code change should work.

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.4.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 22.1.0
    - pnpm: 9.1.0
    - yarn: 1.22.22
    - npm: 10.7.0

[-] Packages
    - tauri [RUST]: 2.0.0-beta.19
    - tauri-build [RUST]: 2.0.0-beta.15
    - wry [RUST]: 0.39.5
    - tao [RUST]: 0.28.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.11
    - @tauri-apps/cli [NPM]: 2.0.0-beta.17

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../out
    - devUrl: http://localhost:3000/
    - framework: React (Next.js)
    - bundler: Webpack

Stack trace

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions