naystack 1.5.34 → 1.5.35

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.
@@ -59,8 +59,9 @@ function withCors(handler, allowedOrigins) {
59
59
  if (!allowedOrigins?.length) return handler;
60
60
  return (async (req) => {
61
61
  const origin = req.headers.get("origin");
62
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
63
- if (origin && !corsHeaders) {
62
+ const isSameOrigin = origin === req.nextUrl.origin;
63
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
64
+ if (origin && !isSameOrigin && !corsHeaders) {
64
65
  return new import_server.NextResponse(null, { status: 403 });
65
66
  }
66
67
  const response = await handler(req);
@@ -22,8 +22,9 @@ function withCors(handler, allowedOrigins) {
22
22
  if (!allowedOrigins?.length) return handler;
23
23
  return (async (req) => {
24
24
  const origin = req.headers.get("origin");
25
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
26
- if (origin && !corsHeaders) {
25
+ const isSameOrigin = origin === req.nextUrl.origin;
26
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
27
+ if (origin && !isSameOrigin && !corsHeaders) {
27
28
  return new NextResponse(null, { status: 403 });
28
29
  }
29
30
  const response = await handler(req);
@@ -65,8 +65,9 @@ function withCors(handler, allowedOrigins) {
65
65
  if (!allowedOrigins?.length) return handler;
66
66
  return (async (req) => {
67
67
  const origin = req.headers.get("origin");
68
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
69
- if (origin && !corsHeaders) {
68
+ const isSameOrigin = origin === req.nextUrl.origin;
69
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
70
+ if (origin && !isSameOrigin && !corsHeaders) {
70
71
  return new import_server.NextResponse(null, { status: 403 });
71
72
  }
72
73
  const response = await handler(req);
@@ -22,8 +22,9 @@ function withCors(handler, allowedOrigins) {
22
22
  if (!allowedOrigins?.length) return handler;
23
23
  return (async (req) => {
24
24
  const origin = req.headers.get("origin");
25
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
26
- if (origin && !corsHeaders) {
25
+ const isSameOrigin = origin === req.nextUrl.origin;
26
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
27
+ if (origin && !isSameOrigin && !corsHeaders) {
27
28
  return new NextResponse(null, { status: 403 });
28
29
  }
29
30
  const response = await handler(req);
@@ -647,8 +647,9 @@ function withCors(handler, allowedOrigins) {
647
647
  if (!allowedOrigins?.length) return handler;
648
648
  return (async (req) => {
649
649
  const origin = req.headers.get("origin");
650
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
651
- if (origin && !corsHeaders) {
650
+ const isSameOrigin = origin === req.nextUrl.origin;
651
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
652
+ if (origin && !isSameOrigin && !corsHeaders) {
652
653
  return new import_server.NextResponse(null, { status: 403 });
653
654
  }
654
655
  const response = await handler(req);
@@ -634,8 +634,9 @@ function withCors(handler, allowedOrigins) {
634
634
  if (!allowedOrigins?.length) return handler;
635
635
  return (async (req) => {
636
636
  const origin = req.headers.get("origin");
637
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
638
- if (origin && !corsHeaders) {
637
+ const isSameOrigin = origin === req.nextUrl.origin;
638
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
639
+ if (origin && !isSameOrigin && !corsHeaders) {
639
640
  return new NextResponse(null, { status: 403 });
640
641
  }
641
642
  const response = await handler(req);
@@ -100,8 +100,9 @@ function withCors(handler, allowedOrigins) {
100
100
  if (!allowedOrigins?.length) return handler;
101
101
  return (async (req) => {
102
102
  const origin = req.headers.get("origin");
103
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
104
- if (origin && !corsHeaders) {
103
+ const isSameOrigin = origin === req.nextUrl.origin;
104
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
105
+ if (origin && !isSameOrigin && !corsHeaders) {
105
106
  return new import_server.NextResponse(null, { status: 403 });
106
107
  }
107
108
  const response = await handler(req);
@@ -81,8 +81,9 @@ function withCors(handler, allowedOrigins) {
81
81
  if (!allowedOrigins?.length) return handler;
82
82
  return (async (req) => {
83
83
  const origin = req.headers.get("origin");
84
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
85
- if (origin && !corsHeaders) {
84
+ const isSameOrigin = origin === req.nextUrl.origin;
85
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
86
+ if (origin && !isSameOrigin && !corsHeaders) {
86
87
  return new NextResponse(null, { status: 403 });
87
88
  }
88
89
  const response = await handler(req);
@@ -43,8 +43,9 @@ function withCors(handler, allowedOrigins) {
43
43
  if (!allowedOrigins?.length) return handler;
44
44
  return (async (req) => {
45
45
  const origin = req.headers.get("origin");
46
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
47
- if (origin && !corsHeaders) {
46
+ const isSameOrigin = origin === req.nextUrl.origin;
47
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
48
+ if (origin && !isSameOrigin && !corsHeaders) {
48
49
  return new import_server.NextResponse(null, { status: 403 });
49
50
  }
50
51
  const response = await handler(req);
@@ -18,8 +18,9 @@ function withCors(handler, allowedOrigins) {
18
18
  if (!allowedOrigins?.length) return handler;
19
19
  return (async (req) => {
20
20
  const origin = req.headers.get("origin");
21
- const corsHeaders = getCorsHeaders(origin, allowedOrigins);
22
- if (origin && !corsHeaders) {
21
+ const isSameOrigin = origin === req.nextUrl.origin;
22
+ const corsHeaders = isSameOrigin ? null : getCorsHeaders(origin, allowedOrigins);
23
+ if (origin && !isSameOrigin && !corsHeaders) {
23
24
  return new NextResponse(null, { status: 403 });
24
25
  }
25
26
  const response = await handler(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.5.34",
3
+ "version": "1.5.35",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",