nextjs-cors 3.0.0-alpha.1 → 3.0.0
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/LICENSE +2 -2
- package/README.md +19 -52
- package/package.json +25 -33
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025-present
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,72 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# nextjs-cors
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](https://github.com/yonycalsin/nextjs-cors/actions/workflows/ci.yml)
|
|
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>
|
|
7
|
-
<a href="https://www.npmjs.com/nextjs-cors" target="_blank">
|
|
8
|
-
<img src="https://img.shields.io/npm/v/nextjs-cors" alt="NPM Version" /></a>
|
|
9
|
-
<a href="https://www.npmjs.com/nextjs-cors" target="_blank">
|
|
10
|
-
<img src="https://img.shields.io/npm/l/nextjs-cors" alt="Package License" /></a>
|
|
11
|
-
<a href="https://www.npmjs.com/nextjs-cors" target="_blank">
|
|
12
|
-
<img src="https://img.shields.io/npm/dm/nextjs-cors" alt="NPM Downloads" /></a>
|
|
13
|
-
<a href="https://github.com/yonycalsin/nextjs-cors"><img src="https://img.shields.io/badge/Github%20Page-nextjs.cors-yellow?style=flat-square&logo=github" /></a>
|
|
14
|
-
<a href="https://github.com/yonycalsin"><img src="https://img.shields.io/badge/Author-Yony%20Calsin-blueviolet?style=flat-square&logo=appveyor" /></a>
|
|
15
|
-
<a href="https://twitter.com/yonycalsin" target="_blank">
|
|
16
|
-
<img src="https://img.shields.io/twitter/follow/yonycalsin.svg?style=social&label=Follow"></a>
|
|
3
|
+
CORS middleware for Next.js API routes.
|
|
17
4
|
|
|
18
5
|
## Installation
|
|
19
6
|
|
|
20
|
-
> First we will have to install, in order to use this wonderful package.
|
|
21
|
-
|
|
22
7
|
```bash
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
#
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# Using pnpm
|
|
30
|
-
pnpm add nextjs-cors@3.0.0-alpha
|
|
8
|
+
npm install nextjs-cors
|
|
9
|
+
# or
|
|
10
|
+
yarn add nextjs-cors
|
|
11
|
+
# or
|
|
12
|
+
pnpm add nextjs-cors
|
|
31
13
|
```
|
|
32
14
|
|
|
33
15
|
## Usage
|
|
34
16
|
|
|
35
|
-
nextjs-cors uses the cors package, so we invite you to check the documentation https://github.com/expressjs/cors
|
|
36
|
-
|
|
37
|
-
> pages/api/whoami.{ts,js}
|
|
38
|
-
|
|
39
17
|
```ts
|
|
40
|
-
import NextCors from
|
|
18
|
+
import NextCors from "nextjs-cors";
|
|
41
19
|
|
|
42
|
-
async function handler(req, res) {
|
|
43
|
-
// Run
|
|
44
|
-
// nextjs-cors uses the cors package, so we invite you to check the documentation https://github.com/expressjs/cors
|
|
20
|
+
export default async function handler(req, res) {
|
|
21
|
+
// Run CORS middleware
|
|
45
22
|
await NextCors(req, res, {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})
|
|
23
|
+
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
|
|
24
|
+
origin: "*",
|
|
25
|
+
optionsSuccessStatus: 200,
|
|
26
|
+
});
|
|
51
27
|
|
|
52
|
-
//
|
|
53
|
-
res.json({ message:
|
|
28
|
+
// Your API logic
|
|
29
|
+
res.json({ message: "Hello NextJs Cors!" });
|
|
54
30
|
}
|
|
55
31
|
```
|
|
56
32
|
|
|
57
|
-
##
|
|
58
|
-
|
|
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).
|
|
60
|
-
|
|
61
|
-
## Stay in touch
|
|
62
|
-
|
|
63
|
-
- Github [@yonycalsin](https://github.com/yonycalsin)
|
|
64
|
-
- Twitter [@yonycalsin](https://twitter.com/yonycalsin)
|
|
65
|
-
|
|
66
|
-
## Contributors
|
|
33
|
+
## Options
|
|
67
34
|
|
|
68
|
-
|
|
35
|
+
This package uses the [cors](https://github.com/expressjs/cors) package. See the [cors documentation](https://github.com/expressjs/cors#configuration-options) for all available options.
|
|
69
36
|
|
|
70
37
|
## License
|
|
71
38
|
|
|
72
|
-
|
|
39
|
+
[MIT](LICENSE)
|
package/package.json
CHANGED
|
@@ -1,58 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextjs-cors",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"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.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nextjs-cors",
|
|
7
|
-
"express-cors",
|
|
8
|
-
"nextjs-express-cors",
|
|
9
7
|
"next-cors",
|
|
10
|
-
"cors-server",
|
|
11
8
|
"cors",
|
|
12
|
-
"nextjs
|
|
9
|
+
"nextjs"
|
|
13
10
|
],
|
|
14
|
-
"homepage": "https://github.com/yonycalsin/nextjs-cors#readme",
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/yonycalsin/nextjs-cors/issues"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/yonycalsin/nextjs-cors.git"
|
|
21
|
-
},
|
|
22
11
|
"license": "MIT",
|
|
23
|
-
"author": "Yony Calsin",
|
|
24
12
|
"main": "dist/index.js",
|
|
25
13
|
"module": "dist/index.mjs",
|
|
26
|
-
"
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"require": "./dist/index.js",
|
|
19
|
+
"import": "./dist/index.mjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
27
22
|
"files": [
|
|
28
23
|
"dist",
|
|
29
|
-
"package.json",
|
|
30
24
|
"README.md"
|
|
31
25
|
],
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"prepublishOnly": "npm run build",
|
|
29
|
+
"changeset": "changeset",
|
|
30
|
+
"version": "changeset version",
|
|
31
|
+
"release": "npm run build && changeset publish"
|
|
36
32
|
},
|
|
37
33
|
"dependencies": {
|
|
38
|
-
"
|
|
34
|
+
"cors": "^2.8.5"
|
|
39
35
|
},
|
|
40
36
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
37
|
+
"@changesets/changelog-github": "^0.5.1",
|
|
38
|
+
"@changesets/cli": "^2.29.7",
|
|
39
|
+
"@types/cors": "^2.8.17",
|
|
40
|
+
"next": "^15.0.0",
|
|
41
|
+
"tsup": "^8.5.0",
|
|
42
|
+
"typescript": "^5.6.0"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
|
-
"next": "
|
|
45
|
+
"next": ">=8.1.1-canary.54"
|
|
47
46
|
},
|
|
48
47
|
"publishConfig": {
|
|
49
48
|
"access": "public"
|
|
50
|
-
},
|
|
51
|
-
"scripts": {
|
|
52
|
-
"clean": "rimraf dist",
|
|
53
|
-
"lint:ts": "tsc --noEmit",
|
|
54
|
-
"dev": "tsup-node --watch",
|
|
55
|
-
"build": "tsup-node",
|
|
56
|
-
"test": "echo \"Testing\""
|
|
57
49
|
}
|
|
58
|
-
}
|
|
50
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@next-cors/core';
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@next-cors/core';
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("@next-cors/core"),module.exports);0&&(module.exports={...require("@next-cors/core")});
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from '@next-cors/core'\n"],"mappings":"iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,2BAAd","names":["src_exports","__toCommonJS","__reExport"]}
|
package/dist/index.mjs
DELETED
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from '@next-cors/core'\n"],"mappings":"AAAA,WAAc","names":[]}
|