bt:// protocol

bt:// protocol

bt:// protocol

Function

bt:// is the project resource protocol used by bt_app internally for WebView. It maps files in the project directory or package bundle to URLs accessible to the page.

This protocol is not a system-level external protocol and is not used to allow the operating system or ordinary browsers to open BT applications. It only takes effect inside the WebView created by bt_app.

Usage

In static mode, app.entry can be written as a relative path: The project resources can be explicitly referenced in the

page:

Path rules

  • bt://app/ will be mapped to the current static entry file, the default is index.html.
- The hostname must be app, for example bt://app/index.html.
  • The path is relative within the project.
- Absolute path cannot be accessed.
  • Cannot contain ...
  • Development mode reads the project directory file, and packaging mode reads the exe tail Bundle.
  • In static mode, the path without extension will fall back to the entry HTML when the resource does not exist, for compatibility with SPA history routing; when the resource with extension does not exist, a resource error will still be returned.

The Content-Type

protocol returns common Content-Types by extension:

ExtensionType
.html .htmtext/html; charset=utf-8
.csstext/css; charset=utf-8
.jsapplication/javascript; charset=utf-8
.jsonapplication/json; charset=utf-8
Corresponding image type
.wasmapplication/wasm
.txttext/plain; charset=utf-8

When debugging

and need to view the protocol request, you can set the environment variable:

Common errors

  • 资源路径无效: The URL path contains illegal encoding or is not a safe relative path.
  • 资源不存在或无法读取: The file is not placed in the project directory, or does not enter the Bundle when packaging.
- 403: The protocol host is not app, or the path is trying to access outside the project.