@akinon/next 1.47.0-rc.3 → 1.47.0-rc.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.47.0-rc.5
4
+
5
+ ### Minor Changes
6
+
7
+ - b9273fd: ZERO-2889: add host headers to requests
8
+
9
+ ## 1.47.0-rc.4
10
+
11
+ ### Minor Changes
12
+
13
+ - 1ec2e9d: ZERO-2895: Update app-fetch to include cookies in headers
14
+
3
15
  ## 1.47.0-rc.3
4
16
 
5
17
  ## 1.47.0-rc.2
package/api/client.ts CHANGED
@@ -52,18 +52,24 @@ async function proxyRequest(...args) {
52
52
  extraHeaders[key.toLowerCase()] = value;
53
53
  }
54
54
 
55
- [
55
+ const excludedHeaders = [
56
56
  'x-forwarded-host',
57
57
  'x-forwarded-proto',
58
58
  'x-forwarded-port',
59
59
  'x-requested-with',
60
60
  'origin',
61
- 'host',
62
61
  'referer',
63
62
  'accept',
64
63
  'content-length',
65
- 'content-type'
66
- ].forEach((header) => delete extraHeaders[header]);
64
+ 'content-type',
65
+ 'host'
66
+ ];
67
+
68
+ excludedHeaders.forEach((header) => {
69
+ if (!settings.includedProxyHeaders?.includes(header)) {
70
+ delete extraHeaders[header];
71
+ }
72
+ });
67
73
 
68
74
  const fetchOptions = {
69
75
  method: req.method,
@@ -146,11 +152,8 @@ async function proxyRequest(...args) {
146
152
  try {
147
153
  const request = await fetch(url, fetchOptions);
148
154
 
149
- // Using NextResponse.json with status 204 will cause an error
150
155
  if (request.status === 204) {
151
- return new Response(null, {
152
- status: 204
153
- });
156
+ return new Response(null, { status: 204 });
154
157
  }
155
158
 
156
159
  let response = {} as any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.47.0-rc.3",
4
+ "version": "1.47.0-rc.5",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "set-cookie-parser": "2.6.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@akinon/eslint-plugin-projectzero": "1.47.0-rc.3",
33
+ "@akinon/eslint-plugin-projectzero": "1.47.0-rc.5",
34
34
  "@types/react-redux": "7.1.30",
35
35
  "@types/set-cookie-parser": "2.4.7",
36
36
  "@typescript-eslint/eslint-plugin": "6.7.4",
package/types/index.ts CHANGED
@@ -192,6 +192,7 @@ export interface Settings {
192
192
  };
193
193
  customNotFoundEnabled: boolean;
194
194
  plugins?: Record<string, Record<string, any>>;
195
+ includedProxyHeaders?: string[];
195
196
  }
196
197
 
197
198
  export interface CacheOptions {
@@ -1,7 +1,7 @@
1
1
  import Settings from 'settings';
2
2
  import { ServerVariables } from './server-variables';
3
3
  import logger from '../utils/log';
4
- import { headers } from 'next/headers';
4
+ import { headers, cookies } from 'next/headers';
5
5
 
6
6
  export enum FetchResponseType {
7
7
  JSON = 'json',
@@ -19,6 +19,7 @@ const appFetch = async <T>(
19
19
 
20
20
  try {
21
21
  const nextHeaders = headers();
22
+ const nextCookies = cookies();
22
23
  ip = nextHeaders.get('x-forwarded-for') ?? '';
23
24
 
24
25
  const commerceUrl = Settings.commerceUrl;
@@ -35,9 +36,11 @@ const appFetch = async <T>(
35
36
 
36
37
  init.headers = {
37
38
  ...(init.headers ?? {}),
39
+ ...(ServerVariables.globalHeaders ?? {}),
38
40
  'Accept-Language': currentLocale.apiValue,
39
41
  'x-currency': ServerVariables.currency,
40
- 'x-forwarded-for': ip
42
+ 'x-forwarded-for': ip,
43
+ cookie: nextCookies.toString()
41
44
  };
42
45
 
43
46
  init.next = {
@@ -5,5 +5,6 @@ const { locales, defaultLocaleValue, defaultCurrencyCode } =
5
5
 
6
6
  export const ServerVariables = {
7
7
  locale: locales.find((l) => l.value === defaultLocaleValue)?.value ?? '',
8
- currency: defaultCurrencyCode
8
+ currency: defaultCurrencyCode,
9
+ globalHeaders: {}
9
10
  };