- License
- ISC
- Install Size
- 4.7 kB/-
- Vulns
- 0
- Published
$
npm install @kard/spa-server$
pnpm add @kard/spa-server$
yarn add @kard/spa-server$
bun add @kard/spa-server$
deno add npm:@kard/spa-server$
vlt install @kard/spa-server# Run locally
$
npx @kard/spa-server$
pnpm exec @kard/spa-server$
npx @kard/spa-server$
bunx @kard/spa-server$
deno run npm:@kard/spa-server$
vlx @kard/spa-serverA simple NodeJS based server allows serving SPA applications with optional API proxy support and all-routes fallback. It developed to test SPA locally, with Puppeteer or Selenium-based frameworks.
Installation
npm add -D @kard/spa-server
Usage
spa-server --proxy=api::http://jsonplaceholder.typicode.com --port=3030 --public=public --fallback=index.html
The example above :
- Will serve static files from
./publicrelative path, on port 3030. - Each file is absent will be replaced with
./public/index.htmlone. - All of the requests sent to
/api/*routes will be redirected tohttp://jsonplaceholder.typicode.combase.
Command-line keys available
--proxy - allows setting API requests redirect (no default)
--port - allows setting the server port to use (default 3000)
--public - allows setting public path (default ./)
--fallback - allows setting fallback file name (default is index.html)
--route - allows setting base route of the app (default is none)