{"id":17757823,"url":"https://github.com/lopatnov/express-reverse-proxy","last_synced_at":"2026-01-20T19:32:13.579Z","repository":{"id":42235034,"uuid":"268659362","full_name":"lopatnov/express-reverse-proxy","owner":"lopatnov","description":"A back-end (Node.js) development tool to serve front-end projects with back-end reverse proxy for API. Configure a tool and serve your front-end projects.","archived":false,"fork":false,"pushed_at":"2023-01-07T19:05:58.000Z","size":2515,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-09T15:30:10.100Z","etag":null,"topics":["backend-server","expressjs","static-server"],"latest_commit_sha":null,"homepage":"https://lopatnov.github.io/express-reverse-proxy/","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lopatnov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null},"funding":{"patreon":"lopatnov"}},"created_at":"2020-06-02T00:02:04.000Z","updated_at":"2021-12-08T12:59:37.000Z","dependencies_parsed_at":"2023-02-07T22:01:42.832Z","dependency_job_id":null,"html_url":"https://github.com/lopatnov/express-reverse-proxy","commit_stats":null,"previous_names":["lopatnov/static-server-express"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lopatnov/express-reverse-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lopatnov%2Fexpress-reverse-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lopatnov%2Fexpress-reverse-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lopatnov%2Fexpress-reverse-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lopatnov%2Fexpress-reverse-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lopatnov","download_url":"https://codeload.github.com/lopatnov/express-reverse-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lopatnov%2Fexpress-reverse-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28610608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T18:56:40.769Z","status":"ssl_error","status_checked_at":"2026-01-20T18:54:26.653Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["backend-server","expressjs","static-server"],"created_at":"2024-10-26T17:09:02.675Z","updated_at":"2026-01-20T19:32:13.555Z","avatar_url":"https://github.com/lopatnov.png","language":"CSS","readme":"# Express reverse proxy CLI tool [![LinkedIn](https://img.shields.io/badge/LinkedIn-lopatnov-informational?style=social\u0026logo=linkedin)](https://www.linkedin.com/in/lopatnov/)\n\nA back-end (Node.js) development tool to serve front-end projects with back-end reverse proxy for API. Configure a tool and serve your front-end projects.\n\n- [Installation](#installation)\n- [Run installed server](#run-installed-server)\n- [Run without installation](#run-without-installation)\n- [Configuration](#configuration)\n- [Configuration Recipes](#configuration-recipes)\n- [Rights and Agreements](#rights-and-agreements)\n\n## Installation\n\n[![https://nodei.co/npm/@lopatnov/express-reverse-proxy.png?downloads=true\u0026downloadRank=true\u0026stars=true](https://nodei.co/npm/@lopatnov/express-reverse-proxy.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/@lopatnov/express-reverse-proxy)\n\n```shell\nnpm install --save-dev @lopatnov/express-reverse-proxy\n```\n\n## Run installed server\n\n```shell\nexpress-reverse-proxy\n```\n\n### Running Options\n\n- `--help` shows command line help\n- `--config \u003cfile name\u003e` sets server configuration file. Default value is `server-config.json`. See [configuration file example by this link](./server-config.json).\n\n```shell\nexpress-reverse-proxy --config ./server-config.json\n```\n\n## Run without installation\n\n```bash\nnpx @lopatnov/express-reverse-proxy\n```\n\n## Configuration\n\nEdit `server-config.json` file\n\n![run process](./www/assets/img/process.png)\n\n### Configure server port\n\n```json\n{\n  \"port\": 8080\n  // ...\n}\n```\n\nTo configure server port, edit `port` variable. The default server port is `8080`.\n\n### Configure `headers` variable\n\nTo set headers for all requests use `headers` variable\n\n```json\n{\n  // ...\n  \"headers\": {\n    \"Access-Control-Allow-Origin\": \"*\"\n  }\n  // ...\n}\n```\n\n### Configure `folders` variable\n\nThe `folders` is a variable to serve static files such as images, CSS files, and JavaScript files.\n\n#### Serve static files from a single directory\n\n```json\n{\n  \"folders\": \"www\"\n}\n```\n\nThis configuration means that the server will serve static files from a local `www` directory. The `folders` variable can changed by a value of relative path like \"./www\", \"../../my-nice-project/www\" or \"./project/my-front-end-files\".\n\n#### Serve static files from multiple directories\n\n```json\n{\n  \"folders\": [\"./www\", \"./mock-json\", \"../../images\"]\n}\n```\n\nThis configuration means that the server will serve static files from multiple directories:\n\n- `./www`\n- `./mock-json`\n- `../../images`\n\n#### Map url path to serve static files from directories\n\n```json\n{\n  \"folders\": {\n    \"/\": \"dist\",\n    \"/api\": \"./mock-json\",\n    \"/assets\": {\n      \"/images\": \"./images\",\n      \"/css\": \"./scss/dist\",\n      \"/script\": \"./scripts\"\n    }\n  }\n}\n```\n\nThis configuration means that the server will serve static files from multiple directories. The url path maps to this directories.\n\nIn example above you can see the next mapping:\n\n```txt\nurl: /\ndirectory: dist\n\nurl: /api\ndirectory: ./mock-json\n\nurl: /assets/images\ndirectory: ./images\n\nurl: /assets/css\ndirectory: ./scss/dist\n\nurl: /assets/script\ndirectory: ./scripts\n```\n\n### Configure `proxy` variable\n\nThe `proxy` variable intended for request redirect to 3rd-party server and getting result of this response.\n\n#### Connect API to front-end project\n\n```json\n{\n  \"port\": 4200,\n  \"folders\": \"www\",\n  \"proxy\": {\n    \"/api\": \"localhost:8000\"\n  }\n}\n```\n\nThis configuration means that the server will serve static files from a local `www` directory on 4200 port with remote API on \u003chttp://localhost:8000\u003e. When the web-site makes request to \"/api\" path, the request will redirect to remote server with \u003clocalhost:8000\u003e address.\n\n### Configure `unhandled` variable\n\nTo handle unhandled requests use `unhandled` variable. It's behavior depends on Accept header. It can be used any accept header.\n\n```json5\n{\n  ...\n  \"unhandled\": {\n    \"html\": { // \u003c-- Accept header for html requests\n      ...\n    },\n    \"json\": { // \u003c-- Accept header for json requests\n      ...\n    },\n    \"xml\": { // \u003c-- Accept header for xml requests\n      ...\n    },\n    \"*\": { // \u003c-- Any accept header\n      ...\n    }\n  }\n  ...\n}\n```\n\nEach accept header can contain its options.\n\n```json5\n\"html\": { // \u003c-- Accept header for HTML requests (for example)\n  \"status\": 307, // \u003c-- Response status code Temporary redirect, see 307 http status code\n  \"headers\": {  // \u003c-- Headers\n    \"Location\": \"/\"\n  }\n},\n\n\"json\": { // \u003c-- Accept header for json requests\n  \"status\": 404, // \u003c-- Response status code Not Found\n  \"send\": { // Response JSON object\n    \"error\": \"JSON Not Found\"\n  }\n},\n\n\"xml\": { // \u003c-- Accept header for XML requests\n  \"status\": 404, // \u003c-- Response status code Not Found\n  \"send\": \"\u003cerror\u003eNot Found\u003c/error\u003e\" // Response is text\n},\n\n\"*\": { // \u003c-- Any accept header\n  \"status\": 404,  // \u003c-- Response status code Not Found\n  \"file\": \"./www/not-found.txt\" // Response read from file \"./www/not-found.txt\"\n}\n```\n\n## Configuration Recipes\n\n### Request a static file, than make request to back-end\n\nServer listening in 8080 port\n\n- Request --\u003e Search static file in \"www\" folder --\u003e File found --\u003e Response is the file\n- Request --\u003e Search static file in \"www\" folder --\u003e File not found --\u003e Make request to back-end \u003chttp://localhost:4000/current-path\u003e --\u003e Response from the back-end\n\n```json\n{\n  \"port\": 8080,\n  \"folders\": \"www\",\n  \"proxy\": \"localhost:4000\"\n}\n```\n\n### Request API by path that starts as `/api`, otherwise request front-end by default\n\nServer listening in 8080 port\n\n- Request --\u003e Search static file in \"www\" folder --\u003e File found --\u003e Response is the file\n- Request --\u003e Search static file in \"www\" folder --\u003e File not found --\u003e Response 404 Not Found\n- Request /api/current-path --\u003e Make request to back-end \u003chttp://localhost:4000/current-path\u003e --\u003e Response from the back-end\n\n```json\n{\n  \"port\": 8080,\n  \"folders\": \"www\",\n  \"proxy\": {\n    \"/api\": \"localhost:4000\"\n  }\n}\n```\n\n## Rights and Agreements\n\nLicense [Apache-2.0](https://github.com/lopatnov/static-server-express/blob/master/LICENSE)\n\nCopyright 2020–2022 Oleksandr Lopatnov\n","funding_links":["https://patreon.com/lopatnov"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flopatnov%2Fexpress-reverse-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flopatnov%2Fexpress-reverse-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flopatnov%2Fexpress-reverse-proxy/lists"}