{"bugs":{"url":"https://github.com/fastify/fastify-cors/issues"},"dist":{"shasum":"ed7b00901d6deb58d969c96f995c1501ce3edd55","tarball":"https://registry.npmjs.org/fastify-cors/-/fastify-cors-1.0.1.tgz","fileCount":8,"integrity":"sha512-7ltGnIseQEnJ2Ma6AxWLpnd+QxRykWfqef6a6XbpZy37zHBJPAykrig7e8IogxMn4Bod0LYAQn4Mwyk9puzrMg==","signatures":[{"sig":"MEQCIEEhpOsrxmG9hSCWAJT6ZODQIadpreKJ53LSO44RO3sNAiABUipc8255OT+vrdqNjDFgorWlmVtMImv63C+1I5mG+g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23554,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcdXUxCRA9TVsSAnZWagAAdC4P/2Rz/HIQ0yS8cLajUFZ6\nd8yuzicqDrKYYKePe1HZdw0bQ6pcIhqLN0I3Fx9m9K9FVGUOVWp4DPTveOeq\nlJBKi55+lrtYbQSS/nlHGaea7EZxclFLxwg36lFrKPVqhnVgb5NnybOe4W2e\nmw+O5PhNT8V6wn5oPu0QZ9LBOk8iRFuHE/p6zJBj20JJRE3rD7oCn/mC2jrc\nXHcBuWgM0XZQRyieeveXEkBqFBXeunW9paOZB1dDr4zcYAFzI6QmGI9I2ut2\nofiAU5f0T6P5cL727EXxNRZ0+9SoThC2OJ/TaWE+2khPMBMJyQunbvxuYhf1\nZK7niDwRy3YBZuSw7gTJUd8COR09ykfQqEyJVF2tdaX1NKZIIffdtaQvoFEH\nTgQc1nnP0s91pIroYMtpiYOGoCAFUmDUW6smh5jogBl9o4I4HFwjJnPYY3NF\ndL26Ds03PXLKE5d26bxRZWdIbXX2G9JRF90EskNDUjvqepMi8UNVg5M1BcN3\nQSZRrN0ckTD3rFSGLX71iQzHQuqp1qMvzlKSkFhXorgyoBkP3QaJAOu6JUA4\n9hAuDLPn1iA2/ySzJBdfVEYzWToRrPoKPM81wcubv+B5hoXS7j+ob2NvlUj3\n+x6+xhXgqlIR3NrMlCjJ+l5VIePex7J45xmEDOHgEa04pm+Gp8kZva06sEf3\nLtPQ\r\n=5m+X\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 `^1.x`\n\n## Install\n```\nnpm i fastify-cors@1\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":"3715e14ea0ccc5174ead19ac6af7c9a5947acd63","license":"MIT","scripts":{"test":"standard && tap test.js"},"_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.8.0","description":"Fastify CORS","directories":{},"maintainers":[{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"cemremengu","email":"cemremengu@gmail.com"},{"name":"delvedor","email":"tommydelved@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"},{"name":"trivikr","email":"trivikr.dev@gmail.com"}],"_nodeVersion":"10.15.1","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":"^1.9.0","standard":"^12.0.1"},"_npmOperationalInternal":{"tmp":"tmp/fastify-cors_1.0.1_1551201585143_0.6378706100094327","host":"s3://npm-registry-packages"},"_id":"fastify-cors@1.0.1","version":"1.0.1"}