tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
84.7k stars 2.55k forks source link

[bug] After compiling prod build can't find index.html when using nextjs #7215

Closed pingvin12 closed 1 year ago

pingvin12 commented 1 year ago

Describe the bug

When running npm run tauri build, the app compiles and whenever you launch it on any platform, tauri will not be able to find index.html and writes out the message below: Could not get requested file. The app works fine under tauri dev.

Reproduction

  1. Set up tauri using nextjs template
  2. run npm run tauri build
  3. run the complied executable

Expected behavior

I'd expect tauri to navigate nextjs directories compiled inside ./out dir, and run the frontend from there.

Platform and versions

[✔] Environment
    - OS: Fedora 38.0.0 X64
    ✔ webkit2gtk-4.0: 2.40.2
    ✔ rsvg2: 2.56.1
    ✔ rustc: 1.70.0-nightly (1459b3128 2023-03-23)
    ✔ Cargo: 1.70.0-nightly (15d090969 2023-03-21)
    ✔ rustup: 1.25.2 (17db695f1 2023-02-01)
    ✔ Rust toolchain: nightly-x86_64-unknown-linux-gnu (default)
    - node: 18.16.0
    - pnpm: 7.30.3
    - yarn: 1.22.19
    - npm: 9.5.1

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.1
    - @tauri-apps/api [NPM]: 1.4.0
    - @tauri-apps/cli [NPM]: 1.4.0

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../out
    - devPath: http://localhost:4200/
    - framework: React (Next.js)
    - bundler: Webpack

Stack trace

`Asset `index.html` not found; fallback to index.html.html`

Additional context

[EDIT]: the repository can be found here: https://github.com/pingvin12/1Pass

amrbashir commented 1 year ago

could you upgrade tauri and tauri-build in src-tauri/Cargo.toml to latest version 1.4 and try again?

pingvin12 commented 1 year ago

Just ran cargo update, and the issue persists.

amrbashir commented 1 year ago

I have used https://github.com/kvnxiao/tauri-nextjs-template to test out next.js with latest tauri and it worked just fine, maybe you have misconfigured your next.js config or tauri config. Please checkout out that repo and see if your configs match theirs, if not, please reach out to us on Discord where we can help you triage the issue.