{"id":15511618,"url":"https://github.com/LasaleFamine/http-server-pwa","last_synced_at":"2025-10-12T08:31:48.907Z","repository":{"id":26529188,"uuid":"109333727","full_name":"LasaleFamine/http-server-pwa","owner":"LasaleFamine","description":":space_invader: http-server alike but for serving and rendering PWA: pwa-server","archived":false,"fork":false,"pushed_at":"2024-12-10T04:39:51.000Z","size":1236,"stargazers_count":15,"open_issues_count":25,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-10T05:13:13.936Z","etag":null,"topics":["bot-render","cli","expressjs","hacktoberfest","historyapifallback","http-server","indexing","puppeteer","pwa","pwa-server"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LasaleFamine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-03T00:40:54.000Z","updated_at":"2023-08-22T15:35:20.000Z","dependencies_parsed_at":"2024-03-27T00:31:57.788Z","dependency_job_id":"2785d01f-725b-44c5-adfd-171032cc9a98","html_url":"https://github.com/LasaleFamine/http-server-pwa","commit_stats":{"total_commits":123,"total_committers":9,"mean_commits":"13.666666666666666","dds":0.6260162601626016,"last_synced_commit":"afd33ee2f3b1583fda256f01bb335b8df0fcb7c5"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasaleFamine%2Fhttp-server-pwa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasaleFamine%2Fhttp-server-pwa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasaleFamine%2Fhttp-server-pwa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasaleFamine%2Fhttp-server-pwa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LasaleFamine","download_url":"https://codeload.github.com/LasaleFamine/http-server-pwa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235489785,"owners_count":18998467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot-render","cli","expressjs","hacktoberfest","historyapifallback","http-server","indexing","puppeteer","pwa","pwa-server"],"created_at":"2024-10-02T09:53:08.788Z","updated_at":"2025-10-12T08:31:43.608Z","avatar_url":"https://github.com/LasaleFamine.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# http-server-pwa aka pwa-server\n\n[![npm](https://img.shields.io/npm/v/http-server-pwa.svg?style=flat)](https://github.com/LasaleFamine/http-server-pwa) [![Build Status](https://travis-ci.com/LasaleFamine/http-server-pwa.svg?branch=master\u0026style=flat)](https://travis-ci.com/LasaleFamine/http-server-pwa) [![Build status](https://ci.appveyor.com/api/projects/status/k5ssy06tt4ru1269?svg=true\u0026style=flat)](https://ci.appveyor.com/project/LasaleFamine/http-server-pwa) [![codecov](https://codecov.io/gh/LasaleFamine/http-server-pwa/badge.svg?branch=master\u0026style=flat)](https://codecov.io/gh/LasaleFamine/http-server-pwa?branch=master)\n\n\u003e http-server alike but for serving and rendering PWA: pwa-server\n\n## What\n\nThis is a different version (btw inspired by) of the insta-ready [http-server](https://github.com/indexzero/http-server), but with some key features to render Progressive Web Apps (or also SPA) correctly for bots like `googlebot` or Facebook crawlers, so your application can be crawled with its content already loaded. This should avoid the killing problem of the SEO for PWAs.\n\n**The server will render as normal, static ExpressJS server for your normal users.**\n\nWorth noting is that the server supports the `history-fallback` behavior. You maybe can avoid that ***#*** (hash) for your PWA navigation ✌️.\n\n## Features\n\nThe server is not \"dependecies-free\" like the original http-server and instead is powered by [ExpressJS](https://github.com/expressjs/express) under the hood and [Puppeter](https://github.com/GoogleChrome/puppeteer/) for render the pages to bots.\n\n* [pupperender](https://github.com/LasaleFamine/pupperender) - Puppeter middleware to render correctly the PWA content for the crawlers.\n* [express-history-api-fallback](https://www.npmjs.com/package/express-history-api-fallback) - to fallback correctly to the `index.html`.\n* [express-http-to-https](https://www.npmjs.com/package/express-http-to-https) - automatically redirect `http` requests to `https`.\n* [devcert](https://github.com/davewasmer/devcert) - Create development certificate on the fly for local `https`. **NOTE: you could be prompted to insert your password before starting the server. This is necessary of using OpenSSL. More info on devcert repository.**\n\n## Production usage\n\nThe server will not create any SSL certificate on the fly when you set `process.env.NODE_ENV = production` even if `--ssl` flag is passed down.\nYou have two alternatives here:\n- use a reverse proxy like [CloudFlare](https://cloudflare.com) and get free certification for your domain - easy peasy\n- use a custom reverse proxy like Nginx and load your certification from there\n\nI currently don't want to support a custom certificate load. PR are always welcome.\n\n## Deploy on Heroku\n\nIn order to make the server work as expected on Heroku services (even on free tier) you must add [the puppeteer-heroku-buildpack](https://github.com/jontewks/puppeteer-heroku-buildpack).\n\nSince recent changes on the platform it is **strongly** suggested to add it from source rather than the buildpack's catalogs.\n\n```bash\n$ heroku buildpacks:set https://github.com/jontewks/puppeteer-heroku-buildpack.git\n```\n\n## Usage\n\nYou can use it programmatically or as a [CLI](#CLI) tool (global or local).\n\n## Install\n\n```\n$ yarn add http-server-pwa\n```\n\n## Usage\n\n```js\nconst httpServerPwa = require('http-server-pwa');\n\nconst server = await httpServerPwa('./dist', {p: 3000});\n//=\u003e Server started -\u003e ./dist localhost:3000\n```\n\n## API\n\n### httpServerPwa(path, [options])\n\n#### path\n\nType: `string`\n\nPath to serve.\n\n#### options\n\n| Name | CLI flag | Type | Default | Description |\n|------|--------------|------|---------|-------------|\n| port | p | `number` | `8080` | Port to use for running the server. |\n| host | h | `string` | `localhost` | Host to use for running the server. |\n| fallback | f | `string` | `index.html` | Fallback HTML file name. |\n| https | s | `boolean` | `false` | Enable HTTPS redirect on `localhost`.|\n| ssl |  | `boolean` | `false` | Enable `devcert` auto-generation of SSL certification for development.|\n| cache | c | `boolean` | `false` | Enable cache for Puppeteer rendering|\n| cacheTTL |  | `number` | `3600` (s) | Seconds until cached content is disregarded and puppeterized again. Only considered when `cache` is true.|\n| debug | d | `boolean` | `false` | If or not show some logs.|\n| gzip | g | `boolean` | `false` | Enable serving of gzipped files if available|\n| brotli | b | `boolean` | `false` | Enable serving of brotli compressed files if available|\n\n\u003e Note: If the gzip and brotli option are both toggled, brotli compressed files will get precedence over gzipped files.\n\n## CLI\n\n```\n$ yarn add --global http-server-pwa\n```\n\n```\n$ http-server-pwa --help # or pwa-server --help\n\n  Usage\n\t  $ http-server-pwa [path] [options]\n\n\tOptions\n\t\t-p --port       Port to use [Default: 8080]\n\t\t-h --host       Host to use [Default: localhost | Windows: 127.0.0.1]\n\t\t-f --fallback   Fallback HTML file name [Default: index.html]\n\t\t-s --https      Enable HTTPS redirect on localhost [Default: false]\n\t\t--ssl           Auto-generation SSL certificate during development [Default: false]\n\t\t-c --cache      Enable cache for Puppeteer rendering [Default: false]\n\t\t--cacheTTL      Seconds until cached content is disregarded and puppeterized again [Default: 3600 (s)].\n\t\t-d --debug      Be more verbose [Default: false]\n\t\t-g --gzip\tEnable serving of gzipped files if available [Default: false]\n\t\t-b --brotli\tEnable serving of brotli compressed files if available [Default: false]\n\t\t-h --help       Show this message\n\n\tExamples\n\t  $ http-server-pwa\n\t  Server started -\u003e ./ localhost:8080\n\t  $ http-server-pwa dist -p 3000\n\t  Server started -\u003e ./dist localhost:3000\n```\n\n\n## License\n\nMIT © [LasaleFamine](https://godev.space)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLasaleFamine%2Fhttp-server-pwa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLasaleFamine%2Fhttp-server-pwa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLasaleFamine%2Fhttp-server-pwa/lists"}