Skip to content

[bug] csp prevents ipc requests on page load/unload when csp: null #14707

@OzymandiasTheGreat

Description

@OzymandiasTheGreat

Describe the bug

I want to run some clean up code on native side when webview reloads, but ipc requests aren't coming through when invoked from pagehide event handler.
I get Fetch API cannot load ipc://localhost/plugin%3Abare-kit%7Cbare_write due to access control checks. Calling same code from anywhere else works fine, it's just the unload handler that causing issues.
I have csp: null in my tauri.conf.json.
I searched for similar issues and couldn't find much, except for #12662 which seems to suggest this issue is also present on page load handlers.
I'm not sure whether this is a bug or I should be using different APIs, but as far as I can see tauri doesn't provide events for webview navigation on JS side.

Reproduction

Try to invoke or emit a rust command from pagehide event handler. CSP prevents the request from coming through.

Expected behavior

I expect the native command to be invoked.

Full tauri info output

[✔] Environment
    - OS: Mac OS 26.1.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ Xcode: 26.2
    ✔ rustc: 1.91.1 (ed61e7d7e 2025-11-07)
    ✔ cargo: 1.91.1 (ea2d97820 2025-10-10)
    ✔ rustup: 1.28.2 (2025-04-28)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 22.12.0
    - npm: 11.6.2

[-] Packages
    - tauri 🦀: 2.9.5
    - tauri-build 🦀: 2.5.3
    - wry 🦀: 0.53.5
    - tao 🦀: 0.34.5
    - tauri-cli 🦀: 2.5.0 (outdated, latest: 2.9.6)
    - @tauri-apps/api  ⱼₛ: 2.9.1
    - @tauri-apps/cli  ⱼₛ: 2.9.6

[-] Plugins
    - tauri-plugin-dialog 🦀: 2.4.2
    - @tauri-apps/plugin-dialog  ⱼₛ: 2.4.2
    - tauri-plugin-clipboard-manager 🦀: 2.3.2
    - @tauri-apps/plugin-clipboard-manager  ⱼₛ: 2.3.2
    - tauri-plugin-fs 🦀: 2.4.4
    - @tauri-apps/plugin-fs  ⱼₛ: not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:8081/
    - framework: React

Stack trace


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