Skip to content

Permission error when calling openUrl(), but only with openWith parameter supplied #3075

@cliambrown

Description

@cliambrown

My app: https://github.com/cliambrown/Playa
(But some of the code below has not been pushed to GitHub — still testing locally.)

The issue:

import { openUrl } from '@tauri-apps/plugin-opener';
...
openUrl('https://www.google.com/'); // ✅️ Works without errors
openUrl('https://www.google.com/', 'firefox'); // ❌️ Does not work and produces an error (see below)

The error:
Unhandled Promise Rejection: Not allowed to open url https://www.google.com/ with firefox

/src-tauri/capabilities/desktop.json

{
  "identifier": "desktop-capability",
  "platforms": [
    "macOS",
    "windows",
    "linux"
  ],
  "windows": [
    "main"
  ],
  "permissions": [
    "window-state:default",
    "opener:default",
    {
      "identifier": "opener:allow-open-url",
      "allow": [
        { "url": "https://www.google.com/" }
      ]
    },
    {
      "identifier": "http:default",
      "allow": [
        { "url": "https://www.google.com/" }
      ]
    },
    "shell:default",
    {
      "identifier": "shell:allow-execute",
      "allow": [
        {
          "name": "firefox",
          "args": true,
          "cmd": "firefox",
          "sidecar": false
        }
      ]
    }
  ]
}

The documentation for the opener plugin mentions permissions to restrict URLs, but it does not mention a specific permission required to be allowed to use the openWith parameter.

While trying to make this work, I added the exact url to the http:default permission and the opener:allow-open-url permission to see if that would help (it did not). However, openUrl(url) works with any URL with no openWith value supplied and with just the "opener:allow-open-url" permission (no specific URLs allowed).

Is there some missing documentation about a permission required to be able to use the openWith parameter? (I know in v1 openWith was restricted to certain values, but that's not indicated for v2, and "firefox" was one of the allowed values in v1.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions