tauri: How to make tauri use http://tauri.localhost/ instead of https://tauri.localhost/ ? The page was blocked since the page was loaded over HTTPS.


Updated @2023-09-17: If anyone has encountered this problem, please pay attention to this PR: Allow http origin on Windows


Is your feature request related to a problem? Please describe. WebView console shows the following errors when we connect to endpoint ‘ws:<URL>/’: Mixed Content: The page at '<URL>' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws:<URL>/'. This request has been blocked; this endpoint must be available over WSS.

Describe the solution you’d like We should allow to set an option in tauri.conf.json to use http://tauri.localhost/ instead of https://tauri.localhost/.

Describe alternatives you’ve considered None.

Additional context

  1. We can NOT use WSS for historical reasons. 2) WS works fine on macOS, but does NOT works on Windows.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 58 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Any fix for this yet? Or we have to use localhost plugin?

Can you post tauri info please ? and whether you added ws: to your csp configuration ?

Also please explain your feature request a bit further and how the api for it should look like, as I am having some trouble understanding your request.

cargo tauri info:

Operating System - Windows, version 10.0.19042 X64
Webview2 - 96.0.1054.41

Node.js environment
  Node.js - 14.15.0
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 6.14.8
  yarn - 1.22.17

Rust environment
  rustc - 1.56.1
  cargo - 1.56.0

App directory structure
/.git
/bin
/build
/change-logs
/dist
/node_modules
/public
/src
/src-tauri
/src-web
/webpack

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../build
  devPath - http://localhost:9091
  framework - React
  bundler - Webpack

The WebView console shows the following errors:

image

Maybe the API looks like this:

"security": {
  "useHttp": true,  // Add an option here, default value is false
  "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'"
}

Any fix for this yet? Or we have to use localhost plugin?

i change the tauri.conf.json > tauri > security > dangerousUseHttpScheme = true,then it work

I met the same problem too. I don’t fetch http protocol request, It always responst status = 400 and the service is not receive request.

I met the same problem.Because of historical reasons can not support wss,in this case windows compiler software becomes unusable, which should be a common situation.

Unfortunately we need the https://tauri.localhost URL to have a secure context enabled. Maybe this is a case where using a localhost is better. https://github.com/tauri-apps/tauri-plugin-localhost/

hi, @lucasfernog

This plugin needs my local yarn start the app and keep it running? I found that the source code can only run localhost, and I can’t use other particular ip as a parameter?

Unfortunately we need the https://tauri.localhost URL to have a secure context enabled. Maybe this is a case where using a localhost is better. https://github.com/tauri-apps/tauri-plugin-localhost/