tauri-apps / tauri-apps/plugins-workspace

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

Open
#3,075 3 comments 0 reactions 0 assignees View on GitHub
plugin: opener type: documentation
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

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](https://v2.tauri.app/reference/javascript/opener/#openurl) 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](https://v1.tauri.app/v1/api/js/shell/#open).)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.