Giter Club home page Giter Club logo

workiva / webdev_proxy Goto Github PK

View Code? Open in Web Editor NEW
11.0 31.0 6.0 230 KB

A simple HTTP proxy for the webdev serve command (a tool authored by the dart team) that adds support for rewriting certain requests, namely rewriting 404s to instead serve the root index (/index.html). This allows developers to work on browser applications (like our own) that use HTML5 routing while still being able to refresh and/or navigate directly to deep links.

License: Other

Dart 21.47% JavaScript 78.44% HTML 0.09%

webdev_proxy's Introduction

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

webdev_proxy's People

Contributors

robbecker-wf avatar evanweible-wf avatar rmconsole-readonly-wk avatar robrbecker avatar rmconsole6-wk avatar wesleybalvanz-wf avatar rmconsole7-wk avatar nickshoust-wf avatar rmconsole4-wk avatar rmconsole5-wk avatar todbachman-wf avatar rm-astro-wf avatar kirkrichardson-wk avatar rmconsole2-wf avatar rmconsole3-wf avatar annawatson-wk avatar greglittlefield-wf avatar migueldedios-wf avatar kimlarson-wk avatar

Stargazers

Roy Adventus avatar J Hughes avatar  avatar clutchJoe avatar Ken Thuku avatar Thomas Erhel avatar nikitared avatar Medson Oliveira avatar Spencer Cornish avatar Standaa avatar Spencer Cornish avatar

Watchers

James Cloos avatar Code Builder avatar  avatar Andrew Kubly avatar David Winn avatar  avatar  avatar  avatar Jason Moore avatar Dustin Pauze avatar  avatar  avatar Jake Jackson avatar Matthew Schlue avatar  avatar Phoenix Mao (Saskatoon) avatar Braeden Young avatar  avatar Larry Lynn avatar  avatar  avatar  avatar Herm Fischer avatar Tyler Rinnan avatar Daniel Harasymiw avatar Yuan Wang avatar Don Whitt avatar  avatar  avatar Elie avatar  avatar

webdev_proxy's Issues

The injected client.js will try to reconnect to the sse endpoint as soon as the port is bound

  1. Run webdev_proxy serve
  2. Open the served port in a chrome browser tab
  3. Terminate the webdev_proxy serve instance
  4. Restart webdev_proxy serve and note that the browser tab immediately tries to reestablish its SSE connection which produces an error in the server logs because the underlying webdev serve process has not yet started

We likely just need to detect this scenario during startup and silence the error on first request to that endpoint (it ends up succeeding as soon as webdev serve has started up).

Support for webdev 3.0

webdev 3.0 was released earlier this year, which triggers this error from webdev_proxy:

This command is only compatible with `webdev >=1.0.1 <3.0.0`, but you currently have webdev 3.0.4 active.
Please run the following to activate a compatible version:
	pub global activate webdev ">=1.0.1 <3.0.0"

SSE passthrough broken

Or else is causing a problem with micro-frontends.

Building the wdesk sdk example app it will not reload properly if one of the micro-frontends is built with DDC. If I use --no-injected-client it's fine. To reproduce just run the app, then reload localhost:8080

webdev 2.4.0
webdev_proxy 0.1.0
dart 2.7.2, 2.11.0-277.0.dev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.