{"tsd":{"directory":"test"},"bugs":{"url":"https://github.com/fastify/fastify-cors/issues"},"dist":{"shasum":"26ef5e1dc186743d091abb7557972080482ce4be","tarball":"https://registry.npmjs.org/fastify-cors/-/fastify-cors-4.0.0.tgz","fileCount":13,"integrity":"sha512-ow3iiiugJEz7aPNQaulgshoJ9PTlslV1aloP1EDoMq2R5LnDX2T12xxMakXu/FDoMp1nJzbAuB813fVtmgKypA==","signatures":[{"sig":"MEUCIHqHiY81lRJqy/inWQh6VkhsL/DGlAjr0TFwlt7t7wYHAiEAmXTxVHA5jrwsUqJ+HFpYRXscqXk6WPMtUvh7G9rhhuw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33156,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesUf6CRA9TVsSAnZWagAAhUgP/1rI4A3lLxZHGcSuEch8\nI5gSdxrq0MgkFY5BLYhgxgukq4cGq4lrACCkfUWHL21XZQNRB3huUdFJWypd\nVTGKlLrwaFysYP2Dl6ClMO+7rWejUReKRPHGOxGKx+i88rs9J8xc7fapG99s\nPtF1YaWb34AsoUXB8Ypq4d6EY9COfi/PB+pSQjkHYFefAcdSd00kyeFmtDqf\njqjpCjGJ8JDnKCjYwA3rnJTcctHmdFrNVXuKaC3bPlnCx8uieTBBTdlvlUGk\nSdvcs03fC1/x49yJSk0lpbe3Tq7KaTo7jgzU4Qi37u+8RWFk4sWkIOUN8wkH\nxETDp0AV6Z+6GBRrOifwJXbhoNt4pPwyZbFJw7ExjL8H5TPAsh2RFPoUe/dy\nOkwc5Vfj+PavN0aL2BvKXvaCBhZdKNo9f6/VSer/oWXSHN79ogIZ4IbmuydJ\nhNoNpqkB49V52J6hmp9JdUTIgq2VFx1DjZupv+ZImvfNXnXaXSuYES4nnQxx\n6C6NU6J71QvGEnvuyz5QJoRRZA2peF2c69MglCAcx9ErcPPzmkloSS6jS6Bq\nluKam5+mj0sggKJ/ANFCqypPwetoqQBl+RAaMWhyVjZHPZIgoof7XslLWPol\nVi6bQdjUshDjFMfVyGnesdbVF7/ePx3ZpQKrIrNXgONfXbRit+n2jMxVcb+M\ndf9K\r\n=lHRb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","name":"fastify-cors","types":"index.d.ts","author":{"url":"http://delved.org","name":"Tomas Della Vedova - @delvedor"},"readme":"# fastify-cors\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)  ![CI workflow](https://github.com/fastify/fastify-cors/workflows/CI%20workflow/badge.svg)\n\n`fastify-cors` enables the use of [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) in a Fastify application.\n\nSupports Fastify versions `3.x`\nPlease refer to [this branch](https://github.com/fastify/fastify-cors/tree/3.x) and related versions for Fastify `^3.x` compatibility.\nPlease refer to [this branch](https://github.com/fastify/fastify-cors/tree/1.x) and related versions for Fastify `^1.x` compatibility.\n\n## Install\n```\nnpm i fastify-cors\n```\n\n## Usage\nRequire `fastify-cors` and register it as any other plugin, it will add a `preHandler` hook and a [wildcard options route](https://github.com/fastify/fastify/issues/326#issuecomment-411360862).\n```js\nconst fastify = require('fastify')()\n\nfastify.register(require('fastify-cors'), { \n  // put your options here\n})\n\nfastify.get('/', (req, reply) => {\n  reply.send({ hello: 'world' })\n})\n\nfastify.listen(3000)\n```\nYou can use it as is without passing any option, or you can configure it as explained below.\n### Options\n* `origin`: Configures the **Access-Control-Allow-Origin** CORS header. The value of origin could be of different types:\n  - `Boolean` - set `origin` to `true` to reflect the [request origin](http://tools.ietf.org/html/draft-abarth-origin-09), or set it to `false` to disable CORS.\n  - `String` - set `origin` to a specific origin. For example if you set it to `\"http://example.com\"` only requests from \"http://example.com\" will be allowed.\n  - `RegExp` - set `origin` to a regular expression pattern which will be used to test the request origin. If it's a match, the request origin will be reflected. For example the pattern `/example\\.com$/` will reflect any request that is coming from an origin ending with \"example.com\".\n  - `Array` - set `origin` to an array of valid origins. Each origin can be a `String` or a `RegExp`. For example `[\"http://example1.com\", /\\.example2\\.com$/]` will accept any request from \"http://example1.com\" or from a subdomain of \"example2.com\".\n  - `Function` - set `origin` to a function implementing some custom logic. The function takes the request origin as the first parameter and a callback as a second (which expects the signature `err [Error | null], allow [bool]`), *async-await* and promises are supported as well. Fastify instance is bound to function call and you may access via `this`. For example: \n  ```js\n  origin: (origin, cb) => {\n    if(/localhost/.test(origin)){\n      //  Request from localhost will pass\n      cb(null, true)\n      return\n    }\n    cb(new Error(\"Not allowed\"), false)\n  }\n  ```\n* `methods`: Configures the **Access-Control-Allow-Methods** CORS header. Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: `['GET', 'PUT', 'POST']`).\n* `allowedHeaders`: Configures the **Access-Control-Allow-Headers** CORS header. Expects a comma-delimited string (ex: `'Content-Type,Authorization'`) or an array (ex: `['Content-Type', 'Authorization']`). If not specified, defaults to reflecting the headers specified in the request's **Access-Control-Request-Headers** header.\n* `exposedHeaders`: Configures the **Access-Control-Expose-Headers** CORS header. Expects a comma-delimited string (ex: `'Content-Range,X-Content-Range'`) or an array (ex: `['Content-Range', 'X-Content-Range']`). If not specified, no custom headers are exposed.\n* `credentials`: Configures the **Access-Control-Allow-Credentials** CORS header. Set to `true` to pass the header, otherwise it is omitted.\n* `maxAge`: Configures the **Access-Control-Max-Age** CORS header. Set to an integer to pass the header, otherwise it is omitted.\n* `preflightContinue`: Pass the CORS preflight response to the route handler (default: `false`).\n* `optionsSuccessStatus`: Provides a status code to use for successful `OPTIONS` requests, since some legacy browsers (IE11, various SmartTVs) choke on `204`.\n* `preflight`: if needed you can entirely disable preflight by passing `false` here (default: `true`).\n* `hideOptionsRoute`: hide options route from the documentation built using [fastify-swagger](https://github.com/fastify/fastify-swagger) (default: `true`).\n\n## Acknowledgements\n\nThe code is a port for Fastify of [`expressjs/cors`](https://github.com/expressjs/cors).\n\n## License\n\nLicensed under [MIT](./LICENSE).<br/>\n[`expressjs/cors` license](https://github.com/expressjs/cors/blob/master/LICENSE)\n","gitHead":"3b8a4684da9ed1e545c4356deb77180c58d83459","license":"MIT","scripts":{"lint":"npm run lint:standard && npm run lint:typescript","test":"npm run lint && npm run unit && npm run typescript","unit":"tap test/*.test.js","coverage":"tap --cov --coverage-report=html test","lint:fix":"standard --fix","typescript":"tsd","lint:standard":"standard","lint:typescript":"standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin test/types/*.ts"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"homepage":"https://github.com/fastify/fastify-cors#readme","keywords":["fastify","cors","headers","access","control"],"repository":{"url":"git+https://github.com/fastify/fastify-cors.git","type":"git"},"_npmVersion":"6.14.4","description":"Fastify CORS","directories":{},"maintainers":[{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"cemremengu","email":"cemremengu@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"ethan_arrowood","email":"ethan.arrowood@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"starptech","email":"deusdustin@gmail.com"}],"_nodeVersion":"12.16.1","dependencies":{"vary":"^1.1.2","fastify-plugin":"^2.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tap":"^14.10.7","tsd":"^0.11.0","cors":"^2.8.5","fastify":"^3.0.0-rc.1","standard":"^14.0.2","typescript":"^3.5.3","@types/node":"^13.13.4","@typescript-eslint/parser":"^2.0.0","@typescript-eslint/eslint-plugin":"^2.10.0"},"_npmOperationalInternal":{"tmp":"tmp/fastify-cors_4.0.0_1588676601624_0.28495538589615466","host":"s3://npm-registry-packages"},"_id":"fastify-cors@4.0.0","version":"4.0.0"}