Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mattma opened this issue May 17, 2024 · 2 comments
Closed

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

mattma opened this issue May 17, 2024 · 2 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@mattma
Copy link

mattma commented May 17, 2024

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

@mattma mattma added status: needs triage This issue needs to triage, applied to new issues type: bug labels May 17, 2024
@FabianLars
Copy link
Member

Hmm, I feel like it'd be better to reach out to the nextjs community instead. As far as we know we simply need this config and I don't think it's our fault if hmr breaks because of it 🤔

We'd appreciate it if you (or anyone reading this) could take on this :)

@mattma
Copy link
Author

mattma commented May 24, 2024

I confirmed that the issue is indeed on Next.js side. Tauri side works as expected.

@mattma mattma closed this as completed May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants