{"id":13800357,"url":"https://github.com/evert0n/koa-cors","last_synced_at":"2025-04-04T14:04:23.783Z","repository":{"id":12693854,"uuid":"15366176","full_name":"evert0n/koa-cors","owner":"evert0n","description":"CORS middleware for Koa","archived":false,"fork":false,"pushed_at":"2017-09-30T08:06:16.000Z","size":35,"stargazers_count":244,"open_issues_count":13,"forks_count":44,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T13:05:10.322Z","etag":null,"topics":[],"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/evert0n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-21T21:48:38.000Z","updated_at":"2024-12-18T07:03:31.000Z","dependencies_parsed_at":"2022-09-16T20:21:54.394Z","dependency_job_id":null,"html_url":"https://github.com/evert0n/koa-cors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evert0n%2Fkoa-cors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evert0n%2Fkoa-cors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evert0n%2Fkoa-cors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evert0n%2Fkoa-cors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evert0n","download_url":"https://codeload.github.com/evert0n/koa-cors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247186084,"owners_count":20898093,"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":[],"created_at":"2024-08-04T00:01:11.819Z","updated_at":"2025-04-04T14:04:23.758Z","avatar_url":"https://github.com/evert0n.png","language":"JavaScript","funding_links":[],"categories":["仓库"],"sub_categories":["中间件"],"readme":"koa-cors\n========\n\nCORS middleware for Koa\n\nInspired by the great [node-cors](https://github.com/troygoode/node-cors) module.\n\n## Installation (via [npm](https://npmjs.org/package/koa-cors))\n\n```bash\n$ npm install koa-cors\n```\n\n## Usage\n\n```javascript\nvar koa = require('koa');\nvar route = require('koa-route');\nvar cors = require('koa-cors');\nvar app = koa();\n\napp.use(cors());\n\napp.use(route.get('/', function() {\n  this.body = { msg: 'Hello World!' };\n}));\n\napp.listen(3000);\n```\n\n## Options\n\n### origin\n\nConfigures the **Access-Control-Allow-Origin** CORS header. Expects a string\n(ex: http://example.com). Set to `true` to reflect the\n[request origin](http://tools.ietf.org/html/draft-abarth-origin-09), as defined\nby `req.header('Origin')`. Set to `false` to disable CORS. Can also be set to a\nfunction, which takes the request as the first parameter.\n\n### expose\n\nConfigures the **Access-Control-Expose-Headers** CORS header. Expects a\ncomma-delimited string (ex: 'WWW-Authenticate,Server-Authorization') or an array\n(ex: `['WWW-Authenticate', 'Server-Authorization']`). Set this to pass the\nheader, otherwise it is omitted.\n\n### maxAge\n\nConfigures the **Access-Control-Max-Age** CORS header. Set to an integer to pass\nthe header, otherwise it is omitted.\n\n### credentials\n\nConfigures the **Access-Control-Allow-Credentials** CORS header. Set to `true`\nto pass the header, otherwise it is omitted.\n\n### methods\n\nConfigures the **Access-Control-Allow-Methods** CORS header. Expects a\ncomma-delimited string (ex: 'GET,PUT,POST') or an array (ex: `['GET', 'PUT',\n'POST']`).\n\n### headers\nConfigures the **Access-Control-Allow-Headers** CORS header. Expects a\ncomma-delimited string (ex: 'Content-Type,Authorization') or an array (ex:\n`['Content-Type', 'Authorization']`). If not specified, defaults to reflecting\nthe headers specified in the request's **Access-Control-Request-Headers**\nheader.\n\n\nFor details on the effect of each CORS header,\n[read this article on HTML5 Rocks](http://www.html5rocks.com/en/tutorials/cors/).\n\n\n## License\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevert0n%2Fkoa-cors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevert0n%2Fkoa-cors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevert0n%2Fkoa-cors/lists"}