{"id":16127273,"url":"https://github.com/justinbeckwith/yes-https","last_synced_at":"2025-03-15T10:31:03.375Z","repository":{"id":14032720,"uuid":"75701126","full_name":"JustinBeckwith/yes-https","owner":"JustinBeckwith","description":"Say yes to https with express and connect.  ","archived":false,"fork":false,"pushed_at":"2024-04-24T17:54:59.000Z","size":476,"stargazers_count":31,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-24T19:38:37.777Z","etag":null,"topics":["express","https","nodejs"],"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/JustinBeckwith.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-06T06:20:37.000Z","updated_at":"2024-06-10T19:21:24.185Z","dependencies_parsed_at":"2023-01-13T17:45:14.640Z","dependency_job_id":"100b4a25-8f8a-4a0a-b1ab-efed9316af7d","html_url":"https://github.com/JustinBeckwith/yes-https","commit_stats":{"total_commits":70,"total_committers":7,"mean_commits":10.0,"dds":0.6142857142857143,"last_synced_commit":"4eccb9b2ff36c0dd75b5374bf69917459cc7e58d"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinBeckwith%2Fyes-https","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinBeckwith%2Fyes-https/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinBeckwith%2Fyes-https/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JustinBeckwith%2Fyes-https/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JustinBeckwith","download_url":"https://codeload.github.com/JustinBeckwith/yes-https/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243718827,"owners_count":20336590,"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":["express","https","nodejs"],"created_at":"2024-10-09T21:43:40.897Z","updated_at":"2025-03-15T10:31:02.977Z","avatar_url":"https://github.com/JustinBeckwith.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YES HTTPS!\n\n[![Build Status](https://github.com/JustinBeckwith/yes-https/workflows/ci/badge.svg)](https://github.com/JustinBeckwith/yes-https/actions/)\n[![npm version](https://badge.fury.io/js/yes-https.svg)](https://badge.fury.io/js/yes-https)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n`yes-https` is a happy little npm module that makes it easy to require `https` for your connect based application.\n\nIt does this two ways:\n- Setting the `Strict-Transport-Security` HTTP header.  Learn more at [OWASP](https://www.owasp.org/index.php/HTTP_Strict_Transport_Security_Cheat_Sheet).\n- Automatically sending an HTTP 301 for the first request.  This is often overlooked, as HSTS only works after the browser hits the https endpoint the first time.\n\n## Installation\n\n`npm install yes-https`\n\n## Usage\n\n```js\nimport yes from 'yes-https';\nimport express from 'express';\n\nlet app = express();\n\n// Use the yes-https connect middleware.  Note - this will only work if NODE_ENV is set to production.\napp.use(yes());\n\napp.get('/', (req, res) =\u003e {\n  res.end('Thanks for checking it out!');\n});\n\nconst server = app.listen(process.env.PORT || 3000, () =\u003e {\n  console.log('App listening on port %s', server.address().port);\n  console.log('Press Ctrl+C to quit.');\n});\n```\n\nYou can also set a few settings with the middleware to control the header:\n\n```js\napp.use(yes({\n  maxAge: 86400,            // defaults `86400`\n  includeSubdomains: true,  // defaults `true`\n  preload: true             // defaults `true`\n}));\n```\n\n### Ignoring specific requests\n\nIn some cases, you may want to ignore a request and not force the redirect.  You can use the `ignoreFilter` option to opt out of redirects on a case by case basis.  This is useful if you want to ignore a specific route:\n\n```js\napp.use(yes({\n  ignoreFilter: (req) =\u003e {\n    return (req.url.indexOf('/_ah/health') \u003e -1);\n  }\n}));\n```\n\n## Contributing\n\nPull requests welcomed!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinbeckwith%2Fyes-https","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinbeckwith%2Fyes-https","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinbeckwith%2Fyes-https/lists"}