{"id":19272026,"url":"https://github.com/streaver/redhead","last_synced_at":"2025-04-21T22:30:55.912Z","repository":{"id":57349620,"uuid":"168977502","full_name":"streaver/redhead","owner":"streaver","description":"Dynamically setup headers and redirects for you static deployments","archived":false,"fork":false,"pushed_at":"2019-08-05T09:56:16.000Z","size":372,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-06T06:49:54.424Z","etag":null,"topics":["deployment","dynamic","headers","netlify","redirects","static"],"latest_commit_sha":null,"homepage":null,"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/streaver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-03T18:19:41.000Z","updated_at":"2021-01-14T14:05:33.000Z","dependencies_parsed_at":"2022-09-11T13:10:09.566Z","dependency_job_id":null,"html_url":"https://github.com/streaver/redhead","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streaver%2Fredhead","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streaver%2Fredhead/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streaver%2Fredhead/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streaver%2Fredhead/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streaver","download_url":"https://codeload.github.com/streaver/redhead/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223881182,"owners_count":17219261,"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":["deployment","dynamic","headers","netlify","redirects","static"],"created_at":"2024-11-09T20:35:10.459Z","updated_at":"2024-11-09T20:35:11.118Z","avatar_url":"https://github.com/streaver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"RedHead\n===============\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/7522836/52180611-50422c80-27c7-11e9-92c1-3ee2d4b6bd83.png\" height=\"150px\"\u003e\n  \u003cp align=\"center\"\u003eDynamically setup headers and redirects for you static deployments.\u003cp\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://npmjs.org/package/redhead\"\u003e\n      \u003cimg src=\"https://img.shields.io/npm/v/redhead.svg\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://oclif.io\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/cli-oclif-brightgreen.svg\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://circleci.com/gh/streaver/redhead/tree/master\"\u003e\n      \u003cimg src=\"https://circleci.com/gh/streaver/redhead/tree/master.svg?style=shield\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codeclimate.com/github/streaver/redhead/maintainability\"\u003e\n      \u003cimg src=\"https://api.codeclimate.com/v1/badges/3e69b841f5089cb9b11c/maintainability\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codeclimate.com/github/streaver/redhead/test_coverage\"\u003e\n      \u003cimg src=\"https://api.codeclimate.com/v1/badges/3e69b841f5089cb9b11c/test_coverage\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/streaver/redhead/blob/master/LICENSE\"\u003e\n      \u003cimg src=\"https://img.shields.io/github/license/streaver/redhead.svg\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cstrong\u003eWARNING:\u003c/strong\u003e This is still in active development, make sure you lock your versions!\u003cp\u003e\n\n## Motivation\n\nWhen deploying our [website](https://www.streaver.com) we realized we wanted to have a very subtle difference in the redirects if the environment was `staging` or `production`, we could have gone for the ENV variable option, but the [netlify.toml](https://www.netlify.com/docs/netlify-toml-reference/) file does not allow environment variable interpolation, so you end up having to use a `sed` command (or multiple) to do the replacement, something like:\n\n```sh-session\nsed -i s/REDIRECT_1_PLACEHOLDER/${REDIRECT_1_VALUE}/g netlify.toml\nsed -i s/REDIRECT_2_PLACEHOLDER/${REDIRECT_2_VALUE}/g netlify.toml\nyarn build\n```\n\nAfter that, we noticed that many static deployment sites have similar limitations, that lead us to creating [RedHead](https://github.com/streaver/redhead), and now you can simply do:\n\n```sh-session\nredhead build \u0026\u0026 yarn build\n```\n\n## Table of content\n\n* [Installation](#installation)\n* [Supported Platforms](#supported-platforms)\n* [Usage](#usage)\n* [Commands](#commands)\n  * [init](#redhead-init)\n  * [build](#redhead-build)\n  * [help](#redhead-help-command)\n* [Examples](#examples)\n* [Contributing](#contributing)\n* [Credits](#credits)\n\n## Installation\n\n```bash\nyarn global add redhead\n```\n\nOr you can add it to your `package.json`\n\n```bash\nyarn add redhead --dev\n```\n\n\u003c!-- usage --\u003e\n```sh-session\n$ npm install -g redhead\n$ redhead COMMAND\nrunning command...\n$ redhead (-v|--version|version)\nredhead/0.4.0 darwin-x64 node-v11.9.0\n$ redhead --help [COMMAND]\nUSAGE\n  $ redhead COMMAND\n...\n```\n\u003c!-- usagestop --\u003e\n\n## Supported Platforms\n\nWe currently two static deployments, but we plan on adding more (contributions are welcome):\n\n### Currently supported\n\n* [Netlify](https://www.netlify.com/)\n* [Firebase Hosting](https://firebase.google.com/docs/hosting/)\n\n### Plan on supporting\n\n* [Heroku](https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-static)\n\n## Commands\n\n\u003c!-- commands --\u003e\n* [`redhead build`](#redhead-build)\n* [`redhead help [COMMAND]`](#redhead-help-command)\n* [`redhead init`](#redhead-init)\n\n## `redhead build`\n\nGenerate the platform specific files based on the configuration\n\n```\nUSAGE\n  $ redhead build\n\nOPTIONS\n  -o, --output=output              [default: .] Folder where the generated files should be saved.\n  -p, --platform=netlify|firebase  [default: netlify] The target platform for the generated files\n```\n\n_See code: [src/commands/build.js](https://github.com/streaver/redhead/blob/v0.4.0/src/commands/build.js)_\n\n## `redhead help [COMMAND]`\n\ndisplay help for redhead\n\n```\nUSAGE\n  $ redhead help [COMMAND]\n\nARGUMENTS\n  COMMAND  command to show help for\n\nOPTIONS\n  --all  see all commands in CLI\n```\n\n_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.1.6/src/commands/help.ts)_\n\n## `redhead init`\n\nInitialize the required files\n\n```\nUSAGE\n  $ redhead init\n\nOPTIONS\n  -h, --no-headers    Whether or not to handle headers with redhead\n  -r, --no-redirects  Whether or not to handle redirects with redhead\n\nDESCRIPTION\n  Generates files for handling your headers and/or redirects configuration.\n```\n\n_See code: [src/commands/init.js](https://github.com/streaver/redhead/blob/v0.4.0/src/commands/init.js)_\n\u003c!-- commandsstop --\u003e\n\n## Examples\n\n### Different config based on environment\n\nFor example, if you want to have different headers based on the environment you just need to customize the `headers.js` file for your needs and make sure you ENV variables are set for each case, for Netlify this could be done via the `netlify.toml` file.\n\n```js\n// .redhead/headers.js\n\nconst headers = [];\n\nif (process.env.NODE_ENV === 'production') {\n  headers.push({\n    path: '/cool',\n    headers: [\n      'X-Cool: 123'\n    ],\n  });\n}\n\nmodule.exports = headers;\n\n```\n\n### Redirecting one path to the latest post\n\nLet's say you have a blog and want to have a `/latest` path that always takes users to the latest post that has been published, this could be easily achieved with RedHead.\n\n```js\n// .redhead/redirects.js\n\n// use your DB library here;\nconst db = require('db').config(process.env.CONNECTION_URL);\nconst lastPost = db.posts.last();\n\nmodule.exports = [{\n  from: '/latest',\n  to: `${lastPost.permalink}`,\n  status: '302',\n  options: '',\n}];\n\n```\n\n## Contributing\n\nAll contributions or issue reporting are welcomed. If you are filing a bug please include information to help debug it!\n\nIf you plan to contribute, please make sure you test the code.\n\n## Credits\n\n- \u003cdiv\u003eIcon made by \u003ca href=\"https://www.freepik.com/\" title=\"Freepik\"\u003eFreepik\u003c/a\u003e from \u003ca href=\"https://www.flaticon.com/\" \t\t\t    title=\"Flaticon\"\u003ewww.flaticon.com\u003c/a\u003e is licensed by \u003ca href=\"http://creativecommons.org/licenses/by/3.0/\" \t\t\t    title=\"Creative Commons BY 3.0\" target=\"_blank\"\u003eCC 3.0 BY\u003c/a\u003e\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreaver%2Fredhead","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreaver%2Fredhead","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreaver%2Fredhead/lists"}