{"_id":"@lambda-middleware/cors","_rev":"4-1c77f683faa575c110ca2f1f8865601b","name":"@lambda-middleware/cors","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.0":{"name":"@lambda-middleware/cors","version":"1.0.0","keywords":["aws","lambda","middleware","cors","http"],"author":{"name":"Daniel Bartholomae","email":"daniel@bartholomae.name"},"license":"MIT","_id":"@lambda-middleware/cors@1.0.0","maintainers":[{"name":"dbartholomae","email":"daniel@bartholomae.name"}],"homepage":"https://dbartholomae.github.io/lambda-middleware/","bugs":{"url":"https://github.com/dbartholomae/lambda-middleware/issues"},"dist":{"shasum":"90182bf8a9fd3d8034c84c041ab88f01aae122e1","tarball":"https://registry.npmjs.org/@lambda-middleware/cors/-/cors-1.0.0.tgz","fileCount":78,"integrity":"sha512-8Yj87bOGD+W9nQqCcF7mmb8/YA96X2gSnz45EBKVeuwOLiPEEaol6Dd5F+QuekKESYNsAHpSfJFQEap+QkKDdQ==","signatures":[{"sig":"MEYCIQDde4kJZvS+hNDQwNWMJbTxIgDWp/n7g0bepGAOO6Yc8QIhANP7lyovvtuUxOgj85WHlAcNiN4q3c+zbIixjYTb4dEr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":40393,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOaJsCRA9TVsSAnZWagAAjS8P/jpeQ5S4R0JKLK5WL1dC\nKEI5VB1Z/DcGs2NetFBcHoknSjMK1tizCwpDM1DYBi5stsEW3ADET3wmuJqD\nV1C03QHpQrv7IVelV+JC76a7VaeZifk0SeQdipWaYLTGPZXxh8ENnuk8+eim\ncn9tawVh9wh27GJ4o4irU5CzUdxr6Yw5YOGuxENwrikHcQcHVG5MK9jT+8K5\nmimkcrlcsM+zetQtrzdDgGIM2Yz6QzUcpE5QgkBUA65rMJwNdURwp+jLLj7B\nn9u9IPgVPKmnQ9ZpOw+vZFerRZSQl5tA9hg6LOtCfn/HbV26TkSW+fp+yWiK\nMWDiTE5hzpdAEUHZZXTmOltEW97XDno+qE1o9DVOZka48FWkPoXlykNO83BU\niI1t1D6/HkRxB5W/W4MwPv7tecgbgAKgeUgi1ZCBGST3WnSwYkqqxvE+LWC2\n2s9jVlh0Auf7BXDSVTqThNxoKWi19ClYlHEN0GjmVScUxgwVq1G8u84v88pB\nB5YplG8HGj6s7hkcZF3Wr0UHSHYnEst/6tm3XWHR0qApBcufaPfWE3h0jn25\nP7ZAZkJN/SRGSNvq64mM6prL7rGRCXq9fhM8sCd7lvNqFGPIKUYFE5JL8HQ3\nDU2A42o7uZ3ibxsor3Tthgs1mwoUoglqaJXEzTrVPrMM/gqE5X8LepPB6mf/\nKzft\r\n=HbMp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","types":"lib/index.d.ts","engines":{"npm":">= 4.0.0"},"private":false,"scripts":{"lint":"eslint src/**/*.ts examples/**/*.ts","test":"npm run lint && npm run test:unit && npm run test:integration && pkg-ok","build":"rimraf ./lib && tsc --project tsconfig.build.json","start":"cd test && serverless offline","pretest":"npm run build","test:unit":"jest","test:integration":"concurrently --timeout 600000 --kill-others --success first \"cd test && serverless offline\" \"wait-on http://localhost:3000/dev/status && jest -c jest.integration.config.js\""},"_npmUser":{"name":"dbartholomae","email":"daniel@bartholomae.name"},"repository":{"url":"git+ssh://git@github.com/dbartholomae/lambda-middleware.git","type":"git"},"_npmVersion":"6.14.5","description":"AWS lambda middleware for automatically adding CORS headers","directories":{"example":"examples"},"_nodeVersion":"12.16.0","dependencies":{"debug":">=4.1.0","tslib":"^2.0.1","@lambda-middleware/utils":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.2.7","eslint":"^6.8.0","pkg-ok":"^2.3.1","rimraf":"^3.0.2","ts-jest":"^25.3.1","wait-on":"^5.2.0","webpack":"^4.41.5","prettier":"^2.0.2","supertest":"^4.0.2","ts-loader":"^6.2.2","aws-lambda":"^1.0.5","jest-junit":"^10.0.0","serverless":"^1.67.0","typescript":"^3.7.5","@types/jest":"^25.2.1","@types/debug":"^4.1.5","concurrently":"^5.1.0","@types/supertest":"^2.0.8","@types/aws-lambda":"^8.10.47","serverless-offline":"^6.1.4","serverless-webpack":"^5.3.1","source-map-support":"^0.5.16","eslint-config-prettier":"^6.10.1","eslint-plugin-prettier":"^3.1.2","prettier-config-standard":"^1.0.1","@typescript-eslint/parser":"^2.26.0","@typescript-eslint/eslint-plugin":"^2.26.0"},"_npmOperationalInternal":{"tmp":"tmp/cors_1.0.0_1597612652208_0.0923058167779558","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@lambda-middleware/cors","version":"2.0.0","keywords":["aws","lambda","middleware","cors","http"],"author":{"name":"Daniel Bartholomae","email":"daniel@bartholomae.name"},"license":"MIT","_id":"@lambda-middleware/cors@2.0.0","maintainers":[{"name":"dbartholomae","email":"daniel@bartholomae.name"}],"homepage":"https://dbartholomae.github.io/lambda-middleware/","bugs":{"url":"https://github.com/dbartholomae/lambda-middleware/issues"},"dist":{"shasum":"e598bf4f6025a94d1f001e6b0c00988a1e3ca110","tarball":"https://registry.npmjs.org/@lambda-middleware/cors/-/cors-2.0.0.tgz","fileCount":80,"integrity":"sha512-HCHkABM0rdUK81cLw4/At2TIYwNNldvmnbJLGk9C2uwf6+JoWD4UjpxZd31BOl3Pd29IfCnbfkSTk1BLURmg6g==","signatures":[{"sig":"MEUCICY9GKTdFMyjsYPipwbfpX2TlwX3f1DCJjIWVXvuUHs9AiEA17r07AxtuXp1WIm1F/ZZSmrnHzI7QwOT6Hs23JZ+tM8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":41657,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkveyCRA9TVsSAnZWagAAXJgP/2diOpK5wfuLOFY3PI//\n9VbQ3Jq+cLPZj1nyxIKS2X8M9nfIwFAM8zUqkCWR8dbkU8MbK3br/RqLb4vM\ndzPp1nPgI2v4vXRz9n2JqHrB8PHdM88hfqSdHCaOZ7IjTlvROW/EoZ85jd9r\nOltuVinunGAFxn0FNMAtPDXWfQxt/PATUqhc1jsyLJ4BV3RY8mwWAyh7VLFQ\n9l6sNqnl+oNpGFWJ3La/j7webnKBmDQbHe8aZuX6GPUHHHPbF/O8HfIf6cIm\nK8KyZNI2WqJUHP8ib/A3myef1dZKAVLR5kmftu34YYCaxWgbP72rm1iA1k8i\nQ2rCtnqqn4J24PMQiJJBpScCjM/d9nK2Y7EOxdAxWzJcR3LbJbr8wmTLEgC8\ngCbCCBS7kbOQ2W2T2kuaxna3p82BqEGkJcYRj10JsGUtDl2rbR8Enyqbvy9W\nDs2V8TOoUvW1mHUeK25bhi6P8omkHRwHYBaZz+VyphrRroy4AB9CFanDviUt\ntpJY7s1IaCQhK4ppm+bxqIju4BNJuE1n+C2IIa9lt8JiiOyeTI82WgLaSUBN\ntY/NUbdMcllIFss4EFTCs4e1gHNbVdmXs6vPx87ZiixH9BZx5NWHeRziyajT\nrHlklEDlmGEOAelhI05nrAE7SfBJHrTfsieq296smkNjkZ6pYvx0PkSEFRg7\ngiZB\r\n=YvxY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","types":"lib/index.d.ts","engines":{"npm":">= 4.0.0"},"private":false,"scripts":{"lint":"eslint src/**/*.ts examples/**/*.ts","test":"npm run lint && npm run test:unit && npm run test:integration && pkg-ok","build":"rimraf ./lib && tsc --project tsconfig.build.json","start":"cd test && serverless offline","pretest":"npm run build","test:unit":"jest","test:integration":"concurrently --timeout 600000 --kill-others --success first \"cd test && serverless offline\" \"wait-on http://localhost:3000/dev/status && jest -c jest.integration.config.js\""},"_npmUser":{"name":"dbartholomae","email":"daniel@bartholomae.name"},"repository":{"url":"git+ssh://git@github.com/dbartholomae/lambda-middleware.git","type":"git","directory":"packages/cors"},"_npmVersion":"6.14.8","description":"AWS lambda middleware for automatically adding CORS headers","directories":{"example":"examples"},"_nodeVersion":"12.18.3","dependencies":{"debug":">=4.1.0","tslib":"^2.0.1","@lambda-middleware/utils":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.2.7","eslint":"^6.8.0","pkg-ok":"^2.3.1","rimraf":"^3.0.2","ts-jest":"^25.3.1","wait-on":"^5.2.0","webpack":"^4.41.5","prettier":"^2.0.2","supertest":"^4.0.2","ts-loader":"^6.2.2","aws-lambda":"^1.0.5","jest-junit":"^10.0.0","serverless":"^1.67.0","typescript":"^4.0.3","@types/jest":"^25.2.1","@types/debug":"^4.1.5","concurrently":"^5.1.0","@types/supertest":"^2.0.8","@types/aws-lambda":"^8.10.47","serverless-offline":"^6.1.4","serverless-webpack":"^5.3.1","source-map-support":"^0.5.16","eslint-config-prettier":"^6.10.1","eslint-plugin-prettier":"^3.1.2","prettier-config-standard":"^1.0.1","@typescript-eslint/parser":"^2.26.0","@typescript-eslint/eslint-plugin":"^2.26.0"},"_npmOperationalInternal":{"tmp":"tmp/cors_2.0.0_1603467185688_0.31282318737744075","host":"s3://npm-registry-packages"}},"2.1.0":{"name":"@lambda-middleware/cors","version":"2.1.0","description":"AWS lambda middleware for automatically adding CORS headers","homepage":"https://dbartholomae.github.io/lambda-middleware/","license":"MIT","author":{"name":"Daniel Bartholomae","email":"daniel@bartholomae.name"},"main":"lib/index.js","keywords":["aws","lambda","middleware","cors","http"],"types":"lib/index.d.ts","engines":{"npm":">= 4.0.0"},"private":false,"dependencies":{"@lambda-middleware/utils":"^1.1.0","debug":">=4.1.0","tslib":"^2.0.1"},"directories":{"example":"examples"},"scripts":{"build":"rimraf ./lib && tsc --project tsconfig.build.json","lint":"eslint src/**/*.ts examples/**/*.ts","pretest":"npm run build","start":"cd test && serverless offline","test":"npm run lint && npm run test:unit && npm run test:integration && pkg-ok","test:integration":"concurrently --timeout 600000 --kill-others --success first \"cd test && serverless offline\" \"wait-on http://localhost:3000/dev/status && jest -c jest.integration.config.js\"","test:unit":"jest"},"devDependencies":{"@types/debug":"^4.1.5","@types/jest":"^25.2.1","@types/supertest":"^2.0.8","@types/aws-lambda":"^8.10.47","@typescript-eslint/parser":"^2.26.0","@typescript-eslint/eslint-plugin":"^2.26.0","aws-lambda":"^1.0.5","concurrently":"^5.1.0","eslint":"^6.8.0","eslint-config-prettier":"^6.10.1","eslint-plugin-prettier":"^3.1.2","jest":"^25.2.7","jest-junit":"^10.0.0","pkg-ok":"^2.3.1","prettier":"^2.0.2","prettier-config-standard":"^1.0.1","rimraf":"^3.0.2","serverless":"^2.57.0","serverless-offline":"^8.0.0","serverless-webpack":"^5.5.3","source-map-support":"^0.5.16","supertest":"^4.0.2","ts-jest":"^25.3.1","ts-loader":"^6.2.2","typescript":"^4.5.4","wait-on":"^5.2.0","webpack":"^4.41.5"},"repository":{"type":"git","url":"git+ssh://git@github.com/dbartholomae/lambda-middleware.git","directory":"packages/cors"},"bugs":{"url":"https://github.com/dbartholomae/lambda-middleware/issues"},"_id":"@lambda-middleware/cors@2.1.0","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-gY3JDy6TTGK0H4ZiCjMisuw4qPzs/282wcTzFw+Bsms50k4iXKMez62lOw4DiXKNTnuhbW0kizEmtGwdFlkHww==","shasum":"6bec23f5c7749b8308fec4f939bea367661cfd68","tarball":"https://registry.npmjs.org/@lambda-middleware/cors/-/cors-2.1.0.tgz","fileCount":83,"unpackedSize":44458,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDU9lPJDJMBTbKirlce1hxpwuhGexwhFKMMdIQyrIfFWwIgPpOYomJ+6JmU/YYggfX9c+/nnGNa5DLeeusEUbnoQtE="}]},"_npmUser":{"name":"dbartholomae","email":"daniel@bartholomae.name"},"maintainers":[{"name":"dbartholomae","email":"daniel@bartholomae.name"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cors_2.1.0_1748271479637_0.449787812481969"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-16T21:17:31.989Z","modified":"2025-05-26T14:58:00.002Z","1.0.0":"2020-08-16T21:17:32.361Z","2.0.0":"2020-10-23T15:33:05.931Z","2.1.0":"2025-05-26T14:57:59.808Z"},"bugs":{"url":"https://github.com/dbartholomae/lambda-middleware/issues"},"author":{"name":"Daniel Bartholomae","email":"daniel@bartholomae.name"},"license":"MIT","homepage":"https://dbartholomae.github.io/lambda-middleware/","keywords":["aws","lambda","middleware","cors","http"],"repository":{"type":"git","url":"git+ssh://git@github.com/dbartholomae/lambda-middleware.git","directory":"packages/cors"},"description":"AWS lambda middleware for automatically adding CORS headers","maintainers":[{"name":"dbartholomae","email":"daniel@bartholomae.name"}],"readme":"# @lambda-middleware/cors\n\n[![npm version](https://badge.fury.io/js/%40lambda-middleware%2Fcors.svg)](https://npmjs.org/package/@lambda-middleware/cors)\n[![downloads](https://img.shields.io/npm/dw/%40lambda-middleware%2Fcors.svg)](https://npmjs.org/package/@lambda-middleware/cors)\n[![open issues](https://img.shields.io/github/issues-raw/dbartholomae/lambda-middleware.svg)](https://github.com/dbartholomae/lambda-middleware/issues)\n[![debug](https://img.shields.io/badge/debug-blue.svg)](https://github.com/visionmedia/debug#readme)\n[![build status](https://github.com/dbartholomae/lambda-middleware/workflows/.github/workflows/build.yml/badge.svg?branch=main)](https://github.com/dbartholomae/lambda-middleware/actions?query=workflow%3A.github%2Fworkflows%2Fbuild.yml)\n[![codecov](https://codecov.io/gh/dbartholomae/lambda-middleware/branch/main/graph/badge.svg)](https://codecov.io/gh/dbartholomae/lambda-middleware)\n[![dependency status](https://david-dm.org/dbartholomae/lambda-middleware.svg?theme=shields.io)](https://david-dm.org/dbartholomae/lambda-middleware)\n[![devDependency status](https://david-dm.org/dbartholomae/lambda-middleware/dev-status.svg)](https://david-dm.org/dbartholomae/lambda-middleware?type=dev)\n\nAWS lambda middleware for automatically adding CORS headers.\n\n## Lambda middleware\n\nThis middleware is part of the [lambda middleware series](https://dbartholomae.github.io/lambda-middleware/). It can be used independently. It works with both\nAPI Gateway and API Gateway V2 type events.\n\n## Usage\n\n```typescript\nimport { cors } from \"@lambda-middleware/cors\";\nimport { APIGatewayProxyResult } from \"aws-lambda\";\n\n// This is your AWS handler\nasync function helloWorld(): Promise<APIGatewayProxyResult> {\n  return {\n    statusCode: 200,\n    body: \"{}\",\n  };\n}\n\n/**\n * Wrap the handler with the middleware. It can be used just with\n * default options or configured in detail.\n * If you are using an API Gateway or Serverless to deploy, please note\n * that they will overwrite some of these settings and need to be configured\n * separately.\n */\nexport const handler = cors({\n  /**\n   * Configures the Access-Control-Allow-Headers CORS header.\n   * If not set will mirror Access-Control-Request-Headers from the request.\n   */\n  allowedHeaders: [],\n\n  /** Configures the Cache-Control header for the preflight response. */\n  cacheControl: \"max-age: 300\",\n\n  /** Configures the Access-Control-Allow-Credentials CORS header. */\n  allowCredentials: true,\n\n  /** Configures the Access-Control-Expose-Headers CORS header. */\n  exposedHeaders: [\"X-Custom-Header\"],\n\n  /** Configures the Access-Control-Max-Age CORS header. */\n  maxAge: 300,\n\n  /** Configures the Access-Control-Allow-Methods CORS header. */\n  allowedMethods: [\"GET\", \"HEAD\", \"PUT\", \"PATCH\", \"POST\", \"DELETE\"],\n\n  /** Provides a status code to use for successful OPTIONS requests, since some legacy browsers (IE11, various SmartTVs) choke on 204. */\n  optionsSuccessStatus: 204,\n\n  /** Configures the Access-Control-Allow-Origin CORS header. An empty array will set the header to '*'. */\n  allowedOrigins: [\"https://example.com\"],\n\n  /** Whether to call the next middleware or handler in case of a OPTIONS request. */\n  preflightContinue: false,\n})(helloWorld);\n```\n","readmeFilename":"README.md"}