nextjs-cors 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nextjs Cors
|
|
2
2
|
|
|
3
|
-
`Nextjs-Cors` is a
|
|
3
|
+
`Nextjs-Cors` is a node.js package to provide a middleware that can be used to enable CORS with various options in nextjs applications.
|
|
4
4
|
|
|
5
5
|
[](https://github.com/yonycalsin/nextjs-cors/actions/workflows/ci.yml)
|
|
6
6
|
<a href="https://github.com/yonycalsin/nextjs-cors"><img src="https://img.shields.io/spiget/stars/1000?color=brightgreen&label=Star&logo=github" /></a>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<a href="https://twitter.com/yonycalsin" target="_blank">
|
|
16
16
|
<img src="https://img.shields.io/twitter/follow/yonycalsin.svg?style=social&label=Follow"></a>
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Installation
|
|
19
19
|
|
|
20
20
|
> First we will have to install, in order to use this wonderful package.
|
|
21
21
|
|
|
@@ -25,9 +25,12 @@ npm install --save nextjs-cors@latest
|
|
|
25
25
|
|
|
26
26
|
# Using yarn
|
|
27
27
|
yarn add nextjs-cors@latest
|
|
28
|
+
|
|
29
|
+
# Using pnpm
|
|
30
|
+
pnpm add nextjs-cors@latest
|
|
28
31
|
```
|
|
29
32
|
|
|
30
|
-
##
|
|
33
|
+
## Usage
|
|
31
34
|
|
|
32
35
|
nextjs-cors uses the cors package, so we invite you to check the documentation https://github.com/expressjs/cors
|
|
33
36
|
|
|
@@ -51,19 +54,19 @@ async function handler(req, res) {
|
|
|
51
54
|
}
|
|
52
55
|
```
|
|
53
56
|
|
|
54
|
-
##
|
|
57
|
+
## Support for
|
|
55
58
|
|
|
56
59
|
`nextjs-cors` is an open source project licensed by [MIT](LICENSE). You can grow thanks to the sponsors and the support of the amazing sponsors. If you want to join them, [contact me here](https://twitter.com/yonycalsin).
|
|
57
60
|
|
|
58
|
-
##
|
|
61
|
+
## Stay in touch
|
|
59
62
|
|
|
60
63
|
- Github [@yonycalsin](https://github.com/yonycalsin)
|
|
61
64
|
- Twitter [@yonycalsin](https://twitter.com/yonycalsin)
|
|
62
65
|
|
|
63
|
-
##
|
|
66
|
+
## Contributors
|
|
64
67
|
|
|
65
68
|
Thanks to the wonderful people who collaborate with me !
|
|
66
69
|
|
|
67
|
-
##
|
|
70
|
+
## License
|
|
68
71
|
|
|
69
|
-
`nextjs-cors` under [License
|
|
72
|
+
`nextjs-cors` under [License.](LICENSE)
|
|
@@ -6,7 +6,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
6
6
|
|
|
7
7
|
var cors = _interopDefault(require('cors'));
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// And to throw an error when an error happens in a middleware
|
|
10
10
|
|
|
11
11
|
function initMiddleware(middleware) {
|
|
12
12
|
return function (req, res, options) {
|
|
@@ -20,7 +20,7 @@ function initMiddleware(middleware) {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
} //
|
|
23
|
+
} // You can read more about the available options here: https://github.com/expressjs/cors#configuration-options
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var NextCors = /*#__PURE__*/initMiddleware(cors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-cors.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import cors, { CorsOptions, CorsOptionsDelegate } from 'cors'\nimport { NextApiRequest, NextApiResponse } from 'next'\n\n//
|
|
1
|
+
{"version":3,"file":"nextjs-cors.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import cors, { CorsOptions, CorsOptionsDelegate } from 'cors'\nimport { NextApiRequest, NextApiResponse } from 'next'\n\n// Helper method to wait for a middleware to execute before continuing\n// And to throw an error when an error happens in a middleware\nfunction initMiddleware(middleware: typeof cors) {\n return (req: NextApiRequest, res: NextApiResponse, options?: CorsOptions | CorsOptionsDelegate) =>\n new Promise((resolve, reject) => {\n middleware(options)(req, res, (result: Error | unknown) => {\n if (result instanceof Error) {\n return reject(result)\n }\n\n return resolve(result)\n })\n })\n}\n\n// You can read more about the available options here: https://github.com/expressjs/cors#configuration-options\nconst NextCors = initMiddleware(cors)\n\nexport default NextCors\n"],"names":["initMiddleware","middleware","req","res","options","Promise","resolve","reject","result","Error","NextCors","cors"],"mappings":";;;;;;;;AAIA;;AACA,SAASA,cAAT,CAAwBC,UAAxB;AACE,SAAO,UAACC,GAAD,EAAsBC,GAAtB,EAA4CC,OAA5C;AAAA,WACL,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV;AACVN,MAAAA,UAAU,CAACG,OAAD,CAAV,CAAoBF,GAApB,EAAyBC,GAAzB,EAA8B,UAACK,MAAD;AAC5B,YAAIA,MAAM,YAAYC,KAAtB,EAA6B;AAC3B,iBAAOF,MAAM,CAACC,MAAD,CAAb;AACD;;AAED,eAAOF,OAAO,CAACE,MAAD,CAAd;AACD,OAND;AAOD,KARD,CADK;AAAA,GAAP;AAUD;;;AAGD,IAAME,QAAQ,gBAAGV,cAAc,CAACW,IAAD,CAA/B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-cors.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["import cors, { CorsOptions, CorsOptionsDelegate } from 'cors'\nimport { NextApiRequest, NextApiResponse } from 'next'\n\n//
|
|
1
|
+
{"version":3,"file":"nextjs-cors.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["import cors, { CorsOptions, CorsOptionsDelegate } from 'cors'\nimport { NextApiRequest, NextApiResponse } from 'next'\n\n// Helper method to wait for a middleware to execute before continuing\n// And to throw an error when an error happens in a middleware\nfunction initMiddleware(middleware: typeof cors) {\n return (req: NextApiRequest, res: NextApiResponse, options?: CorsOptions | CorsOptionsDelegate) =>\n new Promise((resolve, reject) => {\n middleware(options)(req, res, (result: Error | unknown) => {\n if (result instanceof Error) {\n return reject(result)\n }\n\n return resolve(result)\n })\n })\n}\n\n// You can read more about the available options here: https://github.com/expressjs/cors#configuration-options\nconst NextCors = initMiddleware(cors)\n\nexport default NextCors\n"],"names":["initMiddleware","middleware","req","res","options","Promise","resolve","reject","result","Error","cors"],"mappings":"+IAKA,SAASA,EAAeC,UACf,SAACC,EAAqBC,EAAsBC,UACjD,IAAIC,SAAQ,SAACC,EAASC,GACpBN,EAAWG,EAAXH,CAAoBC,EAAKC,GAAK,SAACK,UACzBA,aAAkBC,MACbF,EAAOC,GAGTF,EAAQE,0BAMNR,EAAeU"}
|
package/dist/nextjs-cors.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cors from 'cors';
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// And to throw an error when an error happens in a middleware
|
|
4
4
|
|
|
5
5
|
function initMiddleware(middleware) {
|
|
6
6
|
return function (req, res, options) {
|
|
@@ -14,7 +14,7 @@ function initMiddleware(middleware) {
|
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
-
} //
|
|
17
|
+
} // You can read more about the available options here: https://github.com/expressjs/cors#configuration-options
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
var NextCors = /*#__PURE__*/initMiddleware(cors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-cors.esm.js","sources":["../src/index.ts"],"sourcesContent":["import cors, { CorsOptions, CorsOptionsDelegate } from 'cors'\nimport { NextApiRequest, NextApiResponse } from 'next'\n\n//
|
|
1
|
+
{"version":3,"file":"nextjs-cors.esm.js","sources":["../src/index.ts"],"sourcesContent":["import cors, { CorsOptions, CorsOptionsDelegate } from 'cors'\nimport { NextApiRequest, NextApiResponse } from 'next'\n\n// Helper method to wait for a middleware to execute before continuing\n// And to throw an error when an error happens in a middleware\nfunction initMiddleware(middleware: typeof cors) {\n return (req: NextApiRequest, res: NextApiResponse, options?: CorsOptions | CorsOptionsDelegate) =>\n new Promise((resolve, reject) => {\n middleware(options)(req, res, (result: Error | unknown) => {\n if (result instanceof Error) {\n return reject(result)\n }\n\n return resolve(result)\n })\n })\n}\n\n// You can read more about the available options here: https://github.com/expressjs/cors#configuration-options\nconst NextCors = initMiddleware(cors)\n\nexport default NextCors\n"],"names":["initMiddleware","middleware","req","res","options","Promise","resolve","reject","result","Error","NextCors","cors"],"mappings":";;AAIA;;AACA,SAASA,cAAT,CAAwBC,UAAxB;AACE,SAAO,UAACC,GAAD,EAAsBC,GAAtB,EAA4CC,OAA5C;AAAA,WACL,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV;AACVN,MAAAA,UAAU,CAACG,OAAD,CAAV,CAAoBF,GAApB,EAAyBC,GAAzB,EAA8B,UAACK,MAAD;AAC5B,YAAIA,MAAM,YAAYC,KAAtB,EAA6B;AAC3B,iBAAOF,MAAM,CAACC,MAAD,CAAb;AACD;;AAED,eAAOF,OAAO,CAACE,MAAD,CAAd;AACD,OAND;AAOD,KARD,CADK;AAAA,GAAP;AAUD;;;AAGD,IAAME,QAAQ,gBAAGV,cAAc,CAACW,IAAD,CAA/B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextjs-cors",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Nextjs-Cors is a node.js package to provide a middleware that can be used to enable CORS with various options in nextjs applications.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"nextjs-cors",
|
|
8
8
|
"express-cors",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"module": "dist/nextjs-cors.esm.js",
|
|
26
26
|
"typings": "dist/index.d.ts",
|
|
27
27
|
"files": [
|
|
28
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"package.json",
|
|
30
|
+
"README.md"
|
|
29
31
|
],
|
|
30
32
|
"scripts": {
|
|
31
33
|
"clean": "rimraf dist",
|
|
@@ -56,6 +58,8 @@
|
|
|
56
58
|
"cors": "^2.8.5"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
61
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
62
|
+
"@semantic-release/git": "^10.0.1",
|
|
59
63
|
"@types/cors": "^2.8.12",
|
|
60
64
|
"husky": "^6.0.0",
|
|
61
65
|
"lint-staged": "^10.5.4",
|
|
@@ -64,14 +68,38 @@
|
|
|
64
68
|
"prettier-plugin-organize-imports": "^2.0.0",
|
|
65
69
|
"prettier-plugin-packagejson": "^2.2.5",
|
|
66
70
|
"rimraf": "^3.0.2",
|
|
67
|
-
"semantic-release": "^
|
|
71
|
+
"semantic-release": "^19.0.5",
|
|
68
72
|
"tsdx": "^0.14.1",
|
|
69
73
|
"typescript": "^4.4.2"
|
|
70
74
|
},
|
|
71
75
|
"peerDependencies": {
|
|
72
|
-
"next": "^8.1.1-canary.54 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0"
|
|
76
|
+
"next": "^8.1.1-canary.54 || ^9.0.0 || ^10.0.0-0 || ^11.0.0 || ^12.0.0 || ^13.0.0"
|
|
73
77
|
},
|
|
74
78
|
"publishConfig": {
|
|
75
79
|
"access": "public"
|
|
80
|
+
},
|
|
81
|
+
"release": {
|
|
82
|
+
"branches": [
|
|
83
|
+
"master"
|
|
84
|
+
],
|
|
85
|
+
"plugins": [
|
|
86
|
+
"@semantic-release/commit-analyzer",
|
|
87
|
+
"@semantic-release/release-notes-generator",
|
|
88
|
+
"@semantic-release/npm",
|
|
89
|
+
[
|
|
90
|
+
"@semantic-release/github",
|
|
91
|
+
{
|
|
92
|
+
"assets": [
|
|
93
|
+
"dist/**",
|
|
94
|
+
"package.json",
|
|
95
|
+
"README.md"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"@semantic-release/changelog"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"volta": {
|
|
103
|
+
"node": "14.17.0"
|
|
76
104
|
}
|
|
77
105
|
}
|