@akinon/next 1.47.0-rc.4 → 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,11 @@
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
+
3
9
  ## 1.47.0-rc.4
4
10
 
5
11
  ### Minor Changes
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.4",
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.4",
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 {
@@ -36,6 +36,7 @@ const appFetch = async <T>(
36
36
 
37
37
  init.headers = {
38
38
  ...(init.headers ?? {}),
39
+ ...(ServerVariables.globalHeaders ?? {}),
39
40
  'Accept-Language': currentLocale.apiValue,
40
41
  'x-currency': ServerVariables.currency,
41
42
  'x-forwarded-for': ip,
@@ -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
  };