{"id":13789604,"url":"https://github.com/elysiajs/elysia-cors","last_synced_at":"2025-04-05T04:08:33.187Z","repository":{"id":84990137,"uuid":"574127333","full_name":"elysiajs/elysia-cors","owner":"elysiajs","description":"Plugin for Elysia that for Cross Origin Requests (CORs)","archived":false,"fork":false,"pushed_at":"2024-12-23T15:25:50.000Z","size":316,"stargazers_count":41,"open_issues_count":16,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T03:02:16.976Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/elysiajs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yaml","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},"funding":{"github":"SaltyAom"}},"created_at":"2022-12-04T14:11:10.000Z","updated_at":"2025-03-17T11:08:57.000Z","dependencies_parsed_at":"2024-05-02T11:27:55.651Z","dependency_job_id":"41864991-07ea-49d1-9458-dc4518108995","html_url":"https://github.com/elysiajs/elysia-cors","commit_stats":{"total_commits":40,"total_committers":4,"mean_commits":10.0,"dds":"0.15000000000000002","last_synced_commit":"7ce6d9a64ff5df81d9be5b38c512c38b61fdb179"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elysiajs%2Felysia-cors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elysiajs%2Felysia-cors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elysiajs%2Felysia-cors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elysiajs%2Felysia-cors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elysiajs","download_url":"https://codeload.github.com/elysiajs/elysia-cors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284944,"owners_count":20913704,"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-03T22:00:29.483Z","updated_at":"2025-04-05T04:08:33.141Z","avatar_url":"https://github.com/elysiajs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/SaltyAom"],"categories":["Plugins"],"sub_categories":[],"readme":"# @elysiajs/cors\nPlugin for [elysia](https://github.com/elysiajs/elysia) that for Cross Origin Requests (CORs)\n\n## Installation\n```bash\nbun add @elysiajs/cors\n```\n\n## Example\n```typescript\nimport { Elysia } from 'elysia'\nimport { cors } from '@elysiajs/cors'\n\nconst app = new Elysia()\n    .use(cors())\n    .listen(8080)\n```\n\n## Config\n### origin\n@default `true`\n\nAssign the **Access-Control-Allow-Origin** header.\n\nValue can be one of the following:\n- `string` - String of origin which will directly assign to `Access-Control-Allow-Origin`\n\n- `boolean` - If set to true, `Access-Control-Allow-Origin` will be set to `*` (accept all origin)\n\n- `RegExp` - Pattern to use to test with request's url, will accept origin if matched.\n\n- `Function` - Custom logic to validate origin acceptance or not. will accept origin if `true` is returned.\n    - Function will accepts `Context` just like `Handler`\n    ```typescript\n    // Example usage\n    app.use(cors, {\n        origin: ({ request, headers }) =\u003e true\n    })\n\n    // Type Definition\n    type CORSOriginFn = (context: Context) =\u003e boolean | void\n    ```\n\n- `Array\u003cstring | RegExp | Function\u003e` - Will try to find truthy value of all options above. Will accept Request if one is `true`.\n\n### methods\n@default `*`\n\nAssign **Access-Control-Allow-Methods** header. \n\nValue can be one of the following:\nAccept:\n- `undefined | null | ''` - Ignore all methods.\n\n- `*` - Accept all methods.\n\n- `HTTPMethod` - Will be directly set to **Access-Control-Allow-Methods**.\n    - Expects either a single method or a comma-delimited string (eg: 'GET, PUT, POST')\n\n- `HTTPMethod[]` - Allow multiple HTTP methods.\n    - eg: ['GET', 'PUT', 'POST']\n\n### allowedHeaders\n@default `*`\n\nAssign **Access-Control-Allow-Headers** header. \n\nAllow incoming request with the specified headers.\n\nValue can be one of the following:\n- `string`\n    - Expects either a single method or a comma-delimited string (eg: 'Content-Type, Authorization').\n\n- `string[]` - Allow multiple HTTP methods.\n    - eg: ['Content-Type', 'Authorization']\n\n### exposedHeaders\n@default `*`\n\nAssign **Access-Control-Exposed-Headers** header. \n\nReturn the specified headers to request in CORS mode.\n\nValue can be one of the following:\n- `string`\n    - Expects either a single method or a comma-delimited string (eg: 'Content-Type, 'X-Powered-By').\n\n- `string[]` - Allow multiple HTTP methods.\n    - eg: ['Content-Type', 'X-Powered-By']\n\n### credentials\n@default `true`\n\nAssign **Access-Control-Allow-Credentials** header. \n\nAllow incoming requests to send `credentials` header.\n\n- `boolean` - Available if set to `true`.\n\n### maxAge\n@default `5`\n\nAssign **Access-Control-Max-Age** header. \n\nAllow incoming requests to send `credentials` header.\n\n- `number` - Duration in seconds to indicates how long the results of a preflight request can be cached.\n\n### preflight\n@default `true`\n\nAdd `[OPTIONS] /*` handler to handle preflight request which response with `HTTP 204` and CORS hints.\n\n- `boolean` - Available if set to `true`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felysiajs%2Felysia-cors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felysiajs%2Felysia-cors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felysiajs%2Felysia-cors/lists"}