{"id":14422,"library":"angular-http-server","title":"Single Page App Development Server","description":"angular-http-server is a lightweight command-line interface (CLI) development server designed specifically for Single Page Applications (SPAs) such as those built with Angular, React, or Vue. Its primary function is to serve static assets while routing all non-existent file requests back to the application's `index.html` file, enabling client-side routing without 404 errors. Currently at version 1.12.0, it is actively maintained and provides essential features for local development like custom port assignment, automatic browser opening, HTTPS with self-signed certificates, CORS enablement, and a basic HTTP proxy. It explicitly states it is not intended for production use, focusing solely on streamlining the development workflow by abstracting away complex server configurations for SPA development.","status":"active","version":"1.12.0","language":"javascript","source_language":"en","source_url":"https://github.com/simonh1000/angular-http-server","tags":["javascript","angular","spa","http-server","server","routing"],"install":[{"cmd":"npm install angular-http-server","lang":"bash","label":"npm"},{"cmd":"yarn add angular-http-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add angular-http-server","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a CLI tool and not intended for programmatic JavaScript/TypeScript import or usage. Its primary interaction is via global command line installation and execution.","wrong":"import angularHttpServer from 'angular-http-server'; // Incorrect, this is a CLI tool.","symbol":"angular-http-server CLI command","correct":"npm install -g angular-http-server\n# Then, navigate to your SPA's build directory and run:\nangular-http-server"},{"note":"Configuration options are passed as command-line flags (e.g., `-p` or `--port`) or via a config file, not as JavaScript object literals directly on the command line.","wrong":"angular-http-server port=8080 open=true https=true // Incorrect syntax for flags.","symbol":"Configuration options via CLI flags","correct":"angular-http-server -p 8080 --open --https"},{"note":"A JavaScript config file can export an object of parameters or a function to dynamically configure the server. The `--config` flag tells the CLI to load this file; it's not loaded directly in userland JS.","wrong":"require('./my-server.config.js'); // Incorrect, the CLI loads the config file.","symbol":"Configuration via file","correct":"angular-http-server --config my-server.config.js"}],"quickstart":{"code":"# Install angular-http-server globally to make it available as a command.\n# This is typically a one-time setup for development.\nnpm install -g angular-http-server\n\n# Navigate into your Single Page Application's build output directory.\n# This is usually the 'dist' folder generated by your build process (e.g., Angular CLI, Webpack).\ncd /path/to/your/project/dist\n\n# Start the server with common development options:\n# -p 8080: Specifies port 8080.\n# --open: Automatically opens the application in your default web browser.\n# --https: Enables HTTPS with a self-signed certificate for local development.\n# --cors: Enables Cross-Origin Resource Sharing.\nangular-http-server -p 8080 --open --https --cors\n\n# If your 'index.html' is not directly in the current directory,\n# or you need to serve from a sub-path, use --path:\n# angular-http-server --path my-app-build-folder -p 4200","lang":"sh","description":"Demonstrates global installation and starting the server with common development options like custom port, auto-open, HTTPS, and CORS."},"warnings":[{"fix":"For production deployments, utilize a robust web server like Nginx, Apache, or a Node.js-based solution like Express.js with a reverse proxy, designed for security, performance, and scalability.","message":"This server is explicitly designed for development and testing purposes only and makes no claims to be a production server. Using it in production environments is not recommended and unsupported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For a trusted HTTPS connection, provide your own valid SSL certificate and key using the `--key` and `--cert` flags, or accept the security risk in your browser during local development.","message":"Enabling HTTPS with `--https` or `--ssl` generates a self-signed certificate, which will cause web browsers to display security warnings. This is intended for development and local testing only.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Be aware of this hierarchy. To ensure config file settings are used, avoid overriding them with CLI flags. To debug, check `angular-http-server --help` for flag names and their defaults.","message":"When using a configuration file alongside command-line arguments, CLI options always take precedence and will override any conflicting settings specified in the config file.","severity":"gotcha","affected_versions":">=1.6.0"},{"fix":"Ensure global installation. If you need a programmatic HTTP server for your application, consider alternatives like `http-server` or `serve`.","message":"The package must be installed globally (`npm install -g`) to be used as a command-line tool. It is not designed for programmatic `import` or `require` within other Node.js applications.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install -g angular-http-server` to install the package globally, making the command available.","cause":"The `angular-http-server` package was not installed globally or its executable path is not in your system's PATH environment variable.","error":"angular-http-server: command not found"},{"fix":"Ensure you are running the command from your SPA's build output directory (e.g., `dist/`). Alternatively, use `--path <directory>` to point to the correct folder or `--rootFile <filename.html>` if your entry file is named differently.","cause":"The server could not find the primary `index.html` file in the directory it was started from, or in the path specified by `--path` or `--rootFile`.","error":"Error: Could not locate index.html"},{"fix":"For development, you can proceed by accepting the risk in your browser. For production-like trusted SSL, configure custom certificates using `--key path/to/key.pem` and `--cert path/to/cert.pem`.","cause":"You are using the `--https` flag which generates a self-signed SSL certificate, which is not trusted by web browsers by default.","error":"Browser security warning: 'Your connection is not private' / 'NET::ERR_CERT_AUTHORITY_INVALID'"}],"ecosystem":"npm"}