{"bugs":{"url":"https://github.com/fastify/fastify-cors/issues"},"dist":{"shasum":"702562ec4ba4e69a2aac524f45b3a7bbabeb98ce","tarball":"https://registry.npmjs.org/fastify-cors/-/fastify-cors-2.0.1.tgz","fileCount":8,"integrity":"sha512-NwWiZZOwTP6cH2D6g3Q1vyMfMbOGnTCVXdrozWfI2ecZXnOlkDhpVUTot7gOAQDi1jGwMB7wMOqd/dFXofFs+Q==","signatures":[{"sig":"MEUCIE8LKGWT791r/tQ6+0RpVihfv7gIUePksDdeMjjm6vo7AiEAlRJ9fLzRKKsquWuTOdrj9cbf0PcCjG9secl62phVNpM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23690,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcPDM8CRA9TVsSAnZWagAAeK4P/ivCTKXoMNd8KaZtsUkK\n857UZEj5GQQizEYCausBr8xYP6Zo5u1XEZq9GCd0PKVwceODc9ILsd6luOvK\nVZi2EHxL6kvuosPqEx+G8fHbH+AgK+1ZVkI+/bRNrWiqQQ6zdjL9wZLYHzIx\nzVRmb9gwMBZ6jS7+lU31XiUadBI44HAMpkyxxbpMyFDk+N5SrRwZiZz5XwET\nXKcYZfswDOoEjHgWqqB/HzAJ7cHCj71eUEEbTPWAGYe0dCqZzsU80jIh+/Iq\n/yQwFQAqDIvUB50iYXr4sc9JF9nfl8BlHNIMGSinDEmdujnqX32MnRuP5Lbt\n4jIzkNw4NEMdQf3KiC0JFBe3HBmoIOqu3Ayb03Cs1+gsWOom/3sJRlLzUU63\nF9cwUWRg2vsrsznNHlbmXQSa2sirfHZweAILTLpOXy/z5m+AxXnxvZDuhdwt\nZAA1gkLM1e+Z8mdCu58R3+qoxvOLegN/8VjaHtmqBO7eNGj8oYK5VAUMiCVF\nEh7GcNkM/O/N9uRgAzOWV0j+9108yWENQ0CWUTXjV2s5PWJHLpfjZOQBE9ba\n0u/t4RpMxDNwKZ3LWfa0/tFUekKO2Y1TMW5yqqXaro0Btats5/+syiiJSSYj\nn1+JqJRkum7crONp68K9+J8J7cV13c0ulDMwAwHkRgVl5XaOAGrOn/Na5Mvj\nwXrL\r\n=JvjM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","name":"fastify-cors","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/)  [![Build Status](https://travis-ci.org/fastify/fastify-cors.svg?branch=master)](https://travis-ci.org/fastify/fastify-cors) [![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fastify-cors.svg)](https://greenkeeper.io/)\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 `>=2.x` \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'), { options })\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 [object], allow [bool]`), *async-await* and promises are supported as well. Fastify instance is bound to function call and you may access via `this`.\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\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":"15346e80dc7ede4e6ec3247c88b33192fa05fc4f","license":"MIT","scripts":{"test":"standard && tap test.js"},"_npmUser":{"name":"cemremengu","email":"cemremengu@gmail.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.4.1","description":"Fastify CORS","directories":{},"maintainers":[{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"cemremengu","email":"cemremengu@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"trivikr","email":"trivikr.dev@gmail.com"}],"_nodeVersion":"10.13.0","dependencies":{"vary":"^1.1.2","fastify-plugin":"^1.2.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tap":"^12.0.1","cors":"^2.8.4","fastify":"^2.0.0-rc.2","standard":"^12.0.1"},"_npmOperationalInternal":{"tmp":"tmp/fastify-cors_2.0.1_1547449148324_0.6790807166532777","host":"s3://npm-registry-packages"},"_id":"fastify-cors@2.0.1","version":"2.0.1"}