Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
angular-http-server
Advanced tools
Simple http server for developers of apps with client side routing
A simple dev-server designed for Single Page App (SPA) developers. angular-http-server
is not, and makes no claims to be, a production server.
It returns a file if it exists (ex. your-icon.png, index.html), routes all other requests to index.html (rather than giving a 404 error) so that you SPA's routing can take over. The only time it will error out is if it can't locate the index.html file.
Originally designed for my Angular work, this dev-server will work with any Single Page App (SPA) framework that uses URL routing (React, Vue, Elm, ...).
npm install -g angular-http-server
cd /path/to/site
angular-http-server
And browse to localhost:8080
.
Specify a port using -p <port number>
angular-http-server -p 9000
Open in a default browser automatically by using --open
alias -o
angular-http-server --open
HTTPS can be enabled (using a generated self-signed certificate) with --https
or --ssl
angular-http-server --https
You may manually specify the paths to your self-signed certificate using the --key
and --cert
flags
angular-http-server --https --key ./secret/key.pem --cert ./secret/cert.pem
CORS can be enabled with the --cors flag
angular-http-server --cors
Specify a path to serve from
angular-http-server --path example
Specify the base href of the application
angular-http-server --baseHref myapp
Specify the rootFile of the application
angular-http-server --rootFile myindex.html
Specify the host of the application. It's used when open is true to redirect browser to navigate for the host. Example: http://mydomain.local:8080
angular-http-server --open --host mydomain.local
Disable logging
angular-http-server --silent
All options can be specified by a config file, optionally read via --config
flag.
CLI options take precedence over any options read from the config file.
angular-http-server --config configs/angular-http-server.config.js
Feedback via: https://github.com/simonh1000/angular-http-server
The config file can either export an object of parameters, or a function that will be passed in the parsed argv
from minimalist.
Simple example:
module.exports = {
p: 8081,
cors: true,
silent: true,
};
Complicated example:
module.exports = (argv) => {
const config = {
cors: true,
};
if (argv.p === 443) {
config.ssl = true;
}
return config;
};
The server contains a simple http proxy. The proxy must be configured in the config file. To enable this proxy:
angular-http-server --config configs/angular-http-server.config.js --useProxy true
To configure the proxy add a proxy object to your config file. The proxy should be an array of configs with two required properties: a forward property which must be a string array listing url parts which should trigger the proxy, and a target property which should define the target to proxy to. The config can also contain an optional protocol option, when this is absent the server will default to https
simple example:
module.exports = {
proxy: [
{
forward: ["api/example-api", "api-proxy/example"],
target: "localhost:5000",
protocol: "http",
},
{
forward: ["api/example-api-2", "api-proxy-2/example"],
target: "localhost:6000",
},
],
};
The --https
or --ssl
flags are intended for development and/or testing purposes only. Self-signed certificates do not properly verify the identity of the web app and they will cause an end-users web browser to display an error. This can be accomplished by using the self-signed certificate generated when you pass the --https
/--ssl
flag. An example of when you should use this feature is with end-to-end testing suites such as Protractor or other suites which require the SPA application to be served over https.
Contributions are welcome, but do create an issue first to discuss.
Use prettier for formatting
Run unit tests with
$ npm run test
Testing - try:
node angular-http-server.js --path example --ssl -p 9000
FAQs
Simple http server for developers of apps with client side routing
The npm package angular-http-server receives a total of 23,515 weekly downloads. As such, angular-http-server popularity was classified as popular.
We found that angular-http-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.