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] window.__TAURI__ doesn't get injected if the Entry Url (devPath/distPath) is not an origin url (ie: entry url is a subpage) #4414

Closed
imadbz opened this issue Jun 21, 2022 · 7 comments

Comments

@imadbz
Copy link
Contributor

imadbz commented Jun 21, 2022

Describe the bug

if we specify the url to be an origin (ex: http://localhost:3000), global tauri gets injected in the window.
image

if we specify the url to be an inner page (ex: http://localhost:3000/about), global tauri doesn't get injected.
image

Reproduction

specify devPath to an inner page. (ex: http://localhost:3000/about)
run the app
inspect and check for window.__TAURI vars

Expected behavior

No response

Platform and versions

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

Packages
Error running CLI: only one package mangager should be used, but found npm and yarn
please remove unused package manager lock files
➜  devutil git:(master) ✗ npm run tauri info

> devutil@0.0.0 tauri
> tauri "info"


Environment
  › OS: Mac OS 12.4.0 X64
  › Node.js: 16.15.0
  › npm: 8.10.0
  › pnpm: 6.11.0
  › yarn: Not installed!
  › rustup: 1.24.3
  › rustc: 1.60.0
  › cargo: 1.60.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: ../dist
  › devPath: http://localhost:3000/about
  › framework: Vue.js

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

Stack trace

No response

Additional context

No response

@imadbz
Copy link
Contributor Author

imadbz commented Jun 21, 2022

would write a fix for it if the core team agrees that it is a bug and not an intended behaviour

@lucasfernog
Copy link
Member

Thanks for the report! I just fixed the issue while checking the problem, but will love to see your PR next time ❤️

Fix will be available soon in v1.0.1.

@imadbz
Copy link
Contributor Author

imadbz commented Jun 21, 2022 via email

@Soya-xy
Copy link

Soya-xy commented Jun 27, 2022

When I use tauri::Windows::WindowBuilder create a new window to the URL is not the current devPath (eg: http://localhost:3000), but another project (eg: http://localhost:3333), the other items window.__TAURI__ is undefined if you want to use the tauri API.

Is this currently supported?

All projects run in the same Tauri app, but there are 2 different project addresses

@lucasfernog
Copy link
Member

You'll need to merge both somehow. For instance you can use Webpack dev proxy in development mode, and move all assets to the same folder for production. We don't support multiple dev URLs currently.

@imadbz
Copy link
Contributor Author

imadbz commented Jul 7, 2022

sorry to comment on a closed issue again, but the fix worked for localhost but not if you use an external url (or maybe because of https://, couldn't confirm).

@lucasfernog issue should be reopened?

@FabianLars
Copy link
Member

@imadbz Tauri's apis are intentionally not injected into windows with external urls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants