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] Unhandled Promise Rejection: Scope not defined for URL #9849

Closed
Xutaotaotao opened this issue May 22, 2024 · 2 comments
Closed

[bug] Unhandled Promise Rejection: Scope not defined for URL #9849

Xutaotaotao opened this issue May 22, 2024 · 2 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@Xutaotaotao
Copy link

Describe the bug

When I load https://www.google.com in taruri with this function

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::fs;

use tauri::Manager;

fn read_json_file(path: &str) -> Result<serde_json::Value, Box<dyn std::error::Error>> {
    let content = fs::read_to_string(path)?;
  
    let json: serde_json::Value = serde_json::from_str(&content)?;
  
    Ok(json)
  }

fn main() {
    tauri::Builder::default()
    .setup(|app| {
        let window = app.get_window("main").unwrap();
        let url = "https://www.google.com";
        println!("{}", url);
        let _ = window.eval(&format!("window.location.replace('{}')", url));
        Ok(())
      })
      .run(tauri::generate_context!())
      .expect("error running tauri app");
}

has the error

Unhandled Promise Rejection: Scope not defined for URL

Config is

{
  "build": {
    "beforeDevCommand": "yarn dev",
    "beforeBuildCommand": "yarn build",
    "devPath": "http://localhost:1420",
    "distDir": "../dist"
  },
  "package": {
    "productName": "Knight",
    "version": "0.0.0"
  },
  "tauri": {
    "allowlist": {
      "all": true,
      "shell": {
        "all": true,
        "open": true
      }
    },
    "bundle": {
      "active": true,
      "targets": "all",
      "identifier": "mac.hellobike.knight",
      "icon": [
        "icons/32x32.png",
        "icons/128x128.png",
        "icons/128x128@2x.png",
        "icons/icon.icns",
        "icons/icon.ico"
      ]
    },
    "security": {
      "csp": null,
      "dangerousRemoteDomainIpcAccess": [
        {"domain": "https://www.google.com","windows": ["main"],"enableTauriAPI": true}
      ]
    },
    "windows": [
      {
        "fullscreen": false,
        "resizable": true,
        "title": "test",
        "width": 1366,
        "height": 768,
        "minWidth": 360,
        "minHeight": 600,
        "maxWidth": 480,
        "minimizable":false,
        "maximizable":false
      }
    ]
  }
}

Reproduction

No response

Expected behavior

No response

Full tauri info output

tauri = { version = "1.5", features = [ "api-all"] }

Stack trace

No response

Additional context

No response

@Xutaotaotao Xutaotaotao added status: needs triage This issue needs to triage, applied to new issues type: bug labels May 22, 2024
@FabianLars
Copy link
Member

Try setting the domain in dangerousRemoteDomainIpcAccess to just www.google.com or even google.com.

@Xutaotaotao
Copy link
Author

Thank you very much, solved my big problem!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants