Skip to content

[bug] Tauri API not injected into local web server #4449

@cup-dev

Description

@cup-dev

Describe the bug

My app requires spawning a local web server at http://localhost:8080 to function (both for development and production).

Despite setting http://localhost:8080 as the distDir, devPath, and main window URL, the tauri context is not injected when the window is open (i.e. window.__TAURI__ is undefined).

Reproduction

See minimal repro and steps here: https://github.com/cup-dev/tauri-webserver-issue

Expected behavior

I would expect an ability to spawn a local web server as part of my Tauri app and have the Tauri context available within.

Platform and versions

Environment
  › OS: Mac OS 12.4.0 X64
  › Node.js: 16.15.0
  › npm: 8.5.5
  › pnpm: Not installed!
  › yarn: Not installed!
  › rustup: 1.24.3
  › rustc: 1.59.0
  › cargo: 1.59.0
  › Rust toolchain: stable-aarch64-apple-darwin

Packages
  › @tauri-apps/cli [NPM]: 1.0.0
  › @tauri-apps/api [NPM]: 1.0.1
  › tauri [RUST]: 1.0.0,
  › tauri-build [RUST]: 1.0.0,
  › tao [RUST]: 0.11.2,
  › wry [RUST]: 0.18.3,

App
  › build-type: bundle
  › CSP: unset
  › distDir: http://localhost:8080/
  › devPath: http://localhost:8080/

App directory structure
  ├─ dist
  ├─ node_modules
  ├─ src-tauri
  ├─ site
  └─ .git

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