搜尋套件、儲存庫與 APP 分類

套件詳情v0.1.15

webdev_proxy

一個簡單的 HTTP 代理,用於 webdev 的 serve 命令。透過將 404 錯誤重新寫入根 index,支援使用 HTML5 路由的應用程式。

macOSWindowsLinux
近 30 天下載
5440
喜歡數
5
Pub 分數
140

安裝套件

flutter pub add webdev_proxy

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個輕量級的 HTTP 代理,用於 webdev serve 命令,專為使用 HTML5 路由的 Flutter 應用設計。它攔截 404 錯誤並重新寫入以提供根 index.html 檔案,從而實現無需伺服器設定的順暢客戶端路由。非常適合依賴歷史 API 導航的單頁應用。該代理與 webdev 一同運行,無需更改現有程式碼或建構流程。

適用情境

  • 在Flutter Web應用中支援HTML5路由
  • 使用 404 回退處理客戶端路由
  • 簡化單頁應用的開發
  • 在網頁應用中啟用深度連結
  • 避免伺服器端路由設定

主要特色

  • 將 404 重寫為 index.html
  • 與 webdev serve 結合
  • 所需設定最少
  • 跨平台(macOS、Windows、Linux)
  • 無需程式碼變更

適合對象

  • 使用 HTML5 路由的 Flutter 開發人員
  • Web 上的 SPA 開發人員
  • 本地開發環境
  • 需要深度連結的應用程式
  • 避免複雜伺服器設定的團隊

使用建議

  • 不適用於生產使用
  • 需要執行 webdev
  • 僅限提供靜態資源
  • 不處理動態路由
  • 代理必須手動啟動

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

A simple HTTP proxy for webdev's serve command that adds support for rewriting certain requests, namely rewriting 404s to instead serve the root index (/).

Requirements

The latest release of webdev_proxy requires the following:

Installation

webdev_proxy is intended to be "activated" rather than installed as a package dependency.

$ dart pub global activate webdev_proxy

Learn more about activating and using packages here.

Usage

webdev_proxy supports one command: serve

webdev_proxy serve
Run `webdev serve` (a local web development server) behind a proxy that supports HTML5 routing by rewriting not-found requests to index.html.

Usage: webdev_proxy serve [-- [webdev serve arguments]]
-h, --help                 Print this usage information.
    --[no-]rewrite-404s    Rewrite every request that returns a 404 to /index.html
                           (defaults to on)

Run "webdev_proxy help" to see global options.

You may use any of the following options supported by `webdev serve` by passing them after the `--` separator.

webdev serve --help:
====================

Run a local web development server and a file system watcher that rebuilds on changes.

Usage: webdev serve [arguments] [<directory>[:<port>]]...
-h, --help                        Print this usage information.
-o, --output                      A directory to write the result of a build to. Or a mapping from a top-level directory in the package to the directory to write a filtered build output to. For example
                                  "web:deploy".
                                  A value of "NONE" indicates that no "--output" value should be passed to `build_runner`.
                                  (defaults to "NONE")

-r, --[no-]release                Build with release mode defaults for builders.
    --[no-]build-web-compilers    If a dependency on `build_web_compilers` is required to run.
                                  (defaults to on)

-v, --verbose                     Enables verbose logging.
    --auto                        Automatically performs an action after each build:

                                  restart: Reload modules and re-invoke main (loses current state)
                                  refresh: Performs a full page refresh.
                                  [restart, refresh]

    --chrome-debug-port           Specify which port the Chrome debugger is listening on. If used with launch-in-chrome Chrome will be started with the debugger listening on this port.
    --[no-]debug                  Enable the launching of DevTools (Alt + D). Must use with either --launch-in-chrome or --chrome-debug-port.
    --hostname                    Specify the hostname to serve on.
                                  (defaults to "localhost")

    --[no-]launch-in-chrome       Automatically launches your application in Chrome with the debug port open. Use chrome-debug-port to specify a specific port to attach to an already running chrome instance
                                  instead.

    --log-requests                Enables logging for each request to the server.

Run "webdev help" to see global options.

Note that you can configure the underlying webdev serve process by passing any of its supported command-line arguments after the -- separator.

Examples

To run the default server and proxy:

$ webdev_proxy serve

To pass arguments to webdev serve, e.g. to enable auto-refresh:

$ webdev_proxy serve -- --auto=refresh

所屬分類

依賴

依賴清單 10 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。