{"id":13507979,"url":"https://github.com/whatyouhide/corsica","last_synced_at":"2025-05-14T03:03:01.248Z","repository":{"id":27731212,"uuid":"31218772","full_name":"whatyouhide/corsica","owner":"whatyouhide","description":"Elixir library for dealing with CORS requests. 🏖","archived":false,"fork":false,"pushed_at":"2024-12-22T17:12:58.000Z","size":260,"stargazers_count":528,"open_issues_count":0,"forks_count":38,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-10T19:51:07.305Z","etag":null,"topics":["cors","elixir","elixir-lang","elixir-library","plug"],"latest_commit_sha":null,"homepage":"http://hexdocs.pm/corsica","language":"Elixir","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/whatyouhide.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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":"whatyouhide"}},"created_at":"2015-02-23T17:04:48.000Z","updated_at":"2025-03-28T11:22:02.000Z","dependencies_parsed_at":"2023-02-10T21:00:32.273Z","dependency_job_id":"c7769822-7896-4d71-aec7-c53c52c2c0f1","html_url":"https://github.com/whatyouhide/corsica","commit_stats":{"total_commits":203,"total_committers":20,"mean_commits":10.15,"dds":"0.10344827586206895","last_synced_commit":"d0ccbe60063c3daaee38f8d8fc8cb316bca0fc7b"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fcorsica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fcorsica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fcorsica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whatyouhide%2Fcorsica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whatyouhide","download_url":"https://codeload.github.com/whatyouhide/corsica/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059474,"owners_count":22007767,"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":["cors","elixir","elixir-lang","elixir-library","plug"],"created_at":"2024-08-01T02:00:44.871Z","updated_at":"2025-05-14T03:03:01.176Z","avatar_url":"https://github.com/whatyouhide.png","language":"Elixir","funding_links":["https://github.com/sponsors/whatyouhide"],"categories":["Framework Components","Elixir"],"sub_categories":[],"readme":"# Corsica\n\n[![hex.pm badge](https://img.shields.io/badge/Package%20on%20hex.pm-informational)](https://hex.pm/packages/corsica)\n[![Documentation badge](https://img.shields.io/badge/Documentation-ff69b4)][docs]\n[![CI](https://github.com/whatyouhide/corsica/workflows/CI/badge.svg)](https://github.com/whatyouhide/corsica/actions/workflows/main.yml)\n[![Coverage Status](https://coveralls.io/repos/github/whatyouhide/corsica/badge.svg?branch=main)](https://coveralls.io/github/whatyouhide/corsica?branch=main)\n\nCorsica is a plug and a DSL for handling [CORS][cors-wiki] requests.\n[Documentation can be found online][docs].\n\n![Landscape image of a sunset in Corsica, with the sea in the foreground and mountains in the background](https://user-images.githubusercontent.com/3890250/237011378-833e6fff-fc6b-41b4-94ca-ae75c0109aff.jpg)\n\u003e Photo by \u003ca href=\"https://unsplash.com/@the_bracketeer?utm_source=unsplash\u0026utm_medium=referral\u0026utm_content=creditCopyText\"\u003eHendrik Cornelissen\u003c/a\u003e on \u003ca href=\"https://unsplash.com/photos/b_oRl_WOMVM?utm_source=unsplash\u0026utm_medium=referral\u0026utm_content=creditCopyText\"\u003eUnsplash\u003c/a\u003e\n\n*(I had to include a nice pic because, let's be honest, CORS requests aren't the\nmost fun thing in the world, are they?)*\n\n## Features\n\n* Is compliant with the [W3C CORS specification][cors-spec]\n* Provides both low-level CORS utilities as well as high-level facilities (like\n    a built-in plug and a CORS-focused router)\n* Handles preflight requests like a breeze\n* Never sends any CORS headers if the CORS request is not valid (smaller\n    requests, yay!)\n\n## Installation\n\nAdd the `:corsica` dependency to your project's `mix.exs`:\n\n```elixir\ndefp deps do\n  [\n    {:plug, \"~\u003e 1.0\"},\n    {:corsica, \"~\u003e 2.0\"}\n  ]\nend\n```\n\nand then run `$ mix deps.get`.\n\n## Overview\n\nYou can use Corsica both as a plug as well as a router generator. To use it as a\nplug, just plug it into your plug pipeline:\n\n```elixir\ndefmodule MyApp.Endpoint do\n  plug Logger\n  plug Corsica, origins: \"http://foo.com\"\n  plug MyApp.Router\nend\n```\n\nTo gain finer control over which resources are CORS-enabled and with what\noptions, you can use the `Corsica.Router` module:\n\n```elixir\ndefmodule MyApp.CORS do\n  use Corsica.Router,\n    origins: [\"http://localhost\", ~r{^https?://(.*\\.)?foo\\.com$}],\n    allow_credentials: true,\n    max_age: 600\n\n  resource \"/public/*\", origins: \"*\"\n  resource \"/*\"\nend\n\ndefmodule MyApp.Endpoint do\n  plug Logger\n  plug MyApp.CORS\n  plug MyApp.Router\nend\n```\n\nThis is only a brief overview of what Corsica can do. To find out more, head to\nthe [online documentation][docs].\n\n### Common issues\n\nNote that Corsica is compliant with the W3C CORS specification, which means CORS\nresponse headers are not sent for invalid CORS requests. The documentation goes\ninto more detail about this, but it's worth noting so that the first impression\nis not that Corsica is doing nothing. One common pitfall is not including CORS\nrequest headers in your requests: this makes the request an invalid CORS\nrequest, so Corsica won't add any CORS response headers. Be sure to add at least\nthe `Origin` header:\n\n```sh\ncurl localhost:4000 -v -H \"Origin: http://foo.com\"\n```\n\nThere is a [dedicated page in the documentation](https://hexdocs.pm/corsica/common-issues.html) that covers some of the common issues with CORS (and Corsica in part).\n\n## Contributing\n\nIf you find a bug, something unclear (including in the documentation!) or a\nbehaviour that is not compliant with the latest revision of the\n[official CORS specification][cors-spec], please open an issue on GitHub.\n\nIf you want to contribute to code or documentation, fork the repository and then\nopen a Pull Request\n([how-to](https://help.github.com/articles/using-pull-requests/)). Before\nopening a Pull Request, make sure all the tests passes by running `$ mix test`\nin your shell. If you're contributing to documentation, you can preview the\ngenerated documentation locally by running:\n\n```bash\nmix docs\n```\n\nDocumentation will be generated in the `doc/` directory.\n\n## License\n\nMIT \u0026copy; 2015 Andrea Leopardi, see the [license file](LICENSE.txt).\n\n[docs]: https://hexdocs.pm/corsica\n[cors-wiki]: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing\n[cors-spec]: http://www.w3.org/TR/cors\n[plug]: https://github.com/elixir-lang/plug\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhatyouhide%2Fcorsica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhatyouhide%2Fcorsica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhatyouhide%2Fcorsica/lists"}