搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。