0.14.0 • Published 3 years ago

@spaship/router v0.14.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

SPAship Router

Proxies paths to the right SPA location or pass to different origin.

Testing

CommandPurpose
npm testRun tests.
npm test -- --watchRun tests, and re-run them when files change.

Pull requests and commit messages

This repo follows Conventional Commits, a standard format for writing commit messages. Each commit message becomes an entry in CHANGELOG.md, and the commit messages are also used to determine what version bump to apply.

Read more about Conventional Commits for a description and examples!

If you are working on a pull request, don't worry about commit message format. Commit early and often.

When your pull request is merged, "squash and merge" should be used, and a Conventional Commit message written at that point. In this way, your pull request will become a single commit in the master branch and one entry in the CHANGELOG will be created.

Configuration

Configuration can be provided by CLI flags, environment variables, or a configuration file. Arguments are processed in that order, so CLI flags take precedence over environment variables, which take precedence over the configuration file.

OptionDescriptionCLIEnvconfig.jsonDefault
config fileWhere to find the config file.--config-fileSPASHIP_ROUTER_CONFIG_FILEN/Anone
webrootDirectory to extract/deploy SPAs.--webrootSPASHIP_WEBROOT"webroot"/var/www/html
targetProxy target, httpd location--targetSPASHIP_TARGET"target"http://localhost:8080
portPort to run on.--portSPASHIP_ROUTER_PORT"port"8080
fallbackOptional fallback target if no spa route found--fallbackSPASHIP_FALLBACK"fallback"none
forwarded_hostOptional forwarded host if the router is behind a proxy--forwarded_hostSPASHIP_FORWARDED_HOST"forwarded_host"none
log-levelGranularity of log messages to print. Options are: fatal, error, warn, info, debug, trace or silent.--log-levelSPASHIP_LOG_LEVEL"log_level"info
log-formatpretty for human-friendly logs, json for machine-friendly logs.--log-formatSPASHIP_LOG_FORMAT"log_format"pretty

Note about the filepath configurations, config file and webroot: they must be absolute paths when defined in an environment variable or config file. When defined in CLI options like, they can be written relative to CWD. Example: --config-file=./config.json

Working behind a Proxy

If your setup any proxy before SPAship router, Router have to know the incoming host to send the correct host name to the SPA. There are 2 ways to do it

  1. If your proxy support set x-forwarded-host, You should set up the user facing host on it.

    Ex: www.example.com

    x-forwarded-host: www.example.com
  2. If your proxy not be able to custom, you can use the forwarded_host config parameter.

    Ex: www.example.com

    --forwarded_host=www.example.com

    or

    export SPASHIP_FORWARDED_HOST=www.example.com
0.14.0

3 years ago

0.13.0

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.2

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago