{"_id":"@daveyplate/next-cors-middleware","_rev":"4-a7ff19d5eefdf2459b77013b8d860fe3","name":"@daveyplate/next-cors-middleware","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@daveyplate/next-cors-middleware","version":"1.0.0","keywords":["next","next.js","middleware","cors","cross-origin"],"author":{"name":"LeakedDave"},"license":"ISC","_id":"@daveyplate/next-cors-middleware@1.0.0","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/next-cors-middleware","dist":{"shasum":"285737a0e1b3a93af5259ea543ad21d40da99ddd","tarball":"https://registry.npmjs.org/@daveyplate/next-cors-middleware/-/next-cors-middleware-1.0.0.tgz","fileCount":6,"integrity":"sha512-EvJ0yr+rROxxskDbwEEOs8tPHvPf6Amd9MWYsZe9RaatoHLc+4MPbhl/k6IJq5UCqbVBikrv9TKkDcE8zEI+Kg==","signatures":[{"sig":"MEQCIFJevwZFB1IkDHFIH5WYahUrFYM27SgiWYbzZYnyisqaAiBGZG6yPw4EAnUjESCxqqatXZyvWo4d36dYSxiAqvHCVA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4286},"types":"dist/index","module":"src/index","gitHead":"bf0ca64e1c65201e1c9c69ad82f7a263dfc49bc9","scripts":{"build":"npx tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"10.5.0","description":"Middleware for Next.js to easily enable CORS","directories":{},"_nodeVersion":"20.12.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.2"},"peerDependencies":{"next":">=14.0.0"},"_npmOperationalInternal":{"tmp":"tmp/next-cors-middleware_1.0.0_1731038738446_0.7876185524723023","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@daveyplate/next-cors-middleware","version":"1.0.1","keywords":["next","next.js","middleware","cors","cross-origin"],"author":{"name":"LeakedDave"},"license":"ISC","_id":"@daveyplate/next-cors-middleware@1.0.1","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/next-cors-middleware","dist":{"shasum":"16ec62fd54085bb62cf4010f07bdc4f426194f3d","tarball":"https://registry.npmjs.org/@daveyplate/next-cors-middleware/-/next-cors-middleware-1.0.1.tgz","fileCount":6,"integrity":"sha512-BzNS1zEUH6BSPfgltxTC+7tyJt4hMc/ku8HfUHIuTq/nEFefDWCFdDHAV6iN6ZoPt/BYBGzIlX2UggGyhV9Hfg==","signatures":[{"sig":"MEUCIHS+Ce8U00G+KyjgYUUvOK1vCKzqwuywuIN/dRdCJAjdAiEA/rnczMuMXti38SFwXu/owfJMKUn8MBXLkLGwPPkii7s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4294},"types":"dist/index","module":"src/index","gitHead":"68ee13311ec39b4b08420be5afd827370de7930b","scripts":{"build":"npx tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"10.5.0","description":"Middleware for Next.js to easily enable CORS","directories":{},"_nodeVersion":"20.12.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.2"},"peerDependencies":{"next":">=14.0.0"},"_npmOperationalInternal":{"tmp":"tmp/next-cors-middleware_1.0.1_1731968718778_0.579331145082226","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@daveyplate/next-cors-middleware","version":"1.0.2","keywords":["next","next.js","middleware","cors","cross-origin"],"author":{"name":"daveycodez"},"license":"ISC","_id":"@daveyplate/next-cors-middleware@1.0.2","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/next-cors-middleware","dist":{"shasum":"bc5790e99a47e1e464b4a4e8e4fc9e6a0b146362","tarball":"https://registry.npmjs.org/@daveyplate/next-cors-middleware/-/next-cors-middleware-1.0.2.tgz","fileCount":9,"integrity":"sha512-nrZX3ckdRfABptZTcBZdfnCwwZEC/Hc/6caDcxfryEXuvv9sNB7sY5mElaGVdIhAAsF4nYAUBXHcLOdt/eougg==","signatures":[{"sig":"MEQCIDdHqv2vThJM5/pQB4vNyb7W8K1u5664hTfDmy4uQdipAiA17DvI+hSYxpJrvEmdxUaKPwyt9Py0cixWODdxtiEZRQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":59409},"types":"dist/index","module":"dist/index","gitHead":"fc12ae72d9de8b63b875cfbe17532214894c1425","scripts":{"dev":"tsc --watch","build":"tsc","prepublishOnly":"rm -rf dist && npm run build"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"10.9.0","description":"Middleware for Next.js to easily enable CORS","directories":{},"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.2"},"peerDependencies":{"next":">=14.0.0"},"_npmOperationalInternal":{"tmp":"tmp/next-cors-middleware_1.0.2_1733732715237_0.9378997295019675","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2024-11-08T04:05:38.354Z","modified":"2025-11-21T03:13:05.389Z","1.0.0":"2024-11-08T04:05:38.637Z","1.0.1":"2024-11-18T22:25:18.999Z","1.0.2":"2024-12-09T08:25:15.428Z"},"author":{"name":"daveycodez"},"license":"ISC","homepage":"https://github.com/daveyplate/next-cors-middleware","keywords":["next","next.js","middleware","cors","cross-origin"],"description":"Middleware for Next.js to easily enable CORS","maintainers":[{"email":"leakeddave@me.com","name":"leakeddave"},{"email":"daveycodez@gmail.com","name":"daveycodez"}],"readme":"# @daveyplate/next-cors-middleware\n\n## Installation\n\nTo install the package, run:\n\n```bash\nnpm install @daveyplate/next-cors-middleware\n```\n\n## Middleware Usage\n\nTo use the middleware in your Next.js App, follow these steps:\n\n1. Create a `middleware.js` file in the root of your project:\n\n    ```javascript\n    import { NextResponse } from 'next/server'\n    import { nextCors } from '@daveyplate/next-cors-middleware'\n\n    export function middleware(request) {\n        const response = nextCors({\n            request,\n            allowedOrigins: ['https://example.com', 'https://anotherdomain.com'],\n        })\n\n        if (response) {\n            return response\n        }\n\n        // Your middleware logic here\n        return NextResponse.next()\n    }\n    ```\n\n2. Customize the `allowedOrigins` array with the domains you want to allow.\n\n3. Optionally, you can pass custom CORS options:\n\n    ```javascript\n    const customCorsOptions = {\n        'Access-Control-Allow-Methods': 'GET, POST',\n        'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Custom-Header',\n    };\n\n    export function middleware(request) {\n        const response = nextCors({\n            request,\n            allowedOrigins: ['https://example.com'],\n            corsOptions: customCorsOptions,\n        });\n\n        if (response) {\n            return response;\n        }\n\n        // Your middleware logic here\n        return NextResponse.next();\n    }\n    ```\n\nThat's it! Your Next.js App Router now supports CORS.","readmeFilename":"README.md"}