@akinon/next 1.117.0-rc.7 → 1.117.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/CHANGELOG.md CHANGED
@@ -1,49 +1,6 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.117.0-rc.7
4
-
5
- ### Minor Changes
6
-
7
- - f7e0f646: ZERO-4032: Add bfcache-headers middleware, integrate it into the default chain, and introduce a new environment variable for control.
8
-
9
- ## 1.117.0-rc.6
10
-
11
- ## 1.117.0-rc.5
12
-
13
- ## 1.117.0-rc.4
14
-
15
- ## 1.117.0-rc.3
16
-
17
- ### Minor Changes
18
-
19
- - b59fdd1c: ZERO-4009: Add password reset token validation
20
-
21
- ## 1.117.0-rc.2
22
-
23
- ### Minor Changes
24
-
25
- - 591e345e: ZERO-3855: Enhance credit card payment handling in checkout middlewares
26
-
27
- ## 1.117.0-rc.1
28
-
29
- ### Minor Changes
30
-
31
- - 36143125: ZERO-3987: Add barcode scanner functionality with modal and button
32
-
33
- ## 1.117.0-rc.0
34
-
35
- ### Minor Changes
36
-
37
- - d2c0e759: ZERO-3684: Handle cross-origin iframe access in iframeURLChange function
38
- - b55acb76: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
39
- - 143be2b9: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
40
- - 9f8cd3bc: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
41
- - 729fe756: ZERO-3895: improve non-3D payment handling and error display
42
- - d99a6a7d: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
43
- - d7e5178b: ZERO-3985: Add query string handling for orders redirection in middleware
44
- - 4de5303c: ZERO-2504: add cookie filter to api client request
45
- - 95b139dc: ZERO-3795: Remove duplicate entry for SavedCard in PluginComponents map
46
- - 3909d322: Edit the duplicate Plugin.SimilarProducts in the plugin-module.
3
+ ## 1.117.0
47
4
 
48
5
  ## 1.116.0
49
6
 
@@ -55,7 +55,6 @@ export enum Component {
55
55
  SavedCard = 'SavedCardOption',
56
56
  VirtualTryOnPlugin = 'VirtualTryOnPlugin',
57
57
  BasketVirtualTryOn = 'BasketVirtualTryOn',
58
- BarcodeScannerPlugin = 'BarcodeScannerPlugin',
59
58
  IyzicoSavedCard = 'IyzicoSavedCardOption',
60
59
  Hepsipay = 'Hepsipay',
61
60
  FlowPayment = 'FlowPayment',
@@ -114,10 +113,11 @@ const PluginComponents = new Map([
114
113
  ]
115
114
  ],
116
115
  [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
116
+ [Plugin.SavedCard, [Component.SavedCard]],
117
117
  [Plugin.FlowPayment, [Component.FlowPayment]],
118
118
  [
119
119
  Plugin.VirtualTryOn,
120
- [Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn, Component.BarcodeScannerPlugin]
120
+ [Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
121
121
  ],
122
122
  [Plugin.Hepsipay, [Component.Hepsipay]],
123
123
  [Plugin.MasterpassRest, [Component.MasterpassRest]],
@@ -77,10 +77,6 @@ interface LoyaltyTransactions {
77
77
  }[];
78
78
  }
79
79
 
80
- interface PasswordResetValidateResponse {
81
- validlink: boolean;
82
- }
83
-
84
80
  const accountApi = api.injectEndpoints({
85
81
  endpoints: (builder) => ({
86
82
  updatePassword: builder.mutation<void, AccountChangePasswordFormType>({
@@ -225,12 +221,6 @@ const accountApi = api.injectEndpoints({
225
221
  }),
226
222
  getLoyaltyTransactions: builder.query<LoyaltyTransactions, void>({
227
223
  query: () => buildClientRequestUrl(account.loyaltyTransactions)
228
- }),
229
- getValidatePasswordResetToken: builder.query<
230
- PasswordResetValidateResponse,
231
- string
232
- >({
233
- query: (slug) => buildClientRequestUrl(account.passwordReset(slug))
234
224
  })
235
225
  }),
236
226
  overrideExisting: true
@@ -257,6 +247,5 @@ export const {
257
247
  usePasswordResetMutation,
258
248
  useAnonymizeMutation,
259
249
  useGetLoyaltyBalanceQuery,
260
- useGetLoyaltyTransactionsQuery,
261
- useGetValidatePasswordResetTokenQuery
250
+ useGetLoyaltyTransactionsQuery
262
251
  } = accountApi;
package/data/urls.ts CHANGED
@@ -183,11 +183,7 @@ export const product = {
183
183
  breadcrumbUrl: (menuitemmodel: string) =>
184
184
  `/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
185
185
  bundleProduct: (productPk: string, queryString: string) =>
186
- `/bundle-product/${productPk}/?${queryString}`,
187
- similarProducts: (params?: string) =>
188
- `/similar-products${params ? `?${params}` : ''}`,
189
- similarProductsList: (params?: string) =>
190
- `/similar-product-list${params ? `?${params}` : ''}`
186
+ `/bundle-product/${productPk}/?${queryString}`
191
187
  };
192
188
 
193
189
  export const wishlist = {
@@ -14,8 +14,7 @@ import {
14
14
  withUrlRedirection,
15
15
  withCompleteWallet,
16
16
  withWalletCompleteRedirection,
17
- withMasterpassRestCallback,
18
- withBfcacheHeaders
17
+ withMasterpassRestCallback
19
18
  } from '.';
20
19
  import { urlLocaleMatcherRegex } from '../utils';
21
20
  import withCurrency from './currency';
@@ -129,13 +128,8 @@ const withPzDefault =
129
128
  }
130
129
 
131
130
  if (req.nextUrl.pathname.startsWith('/orders/redirection/')) {
132
- const queryString = searchParams.toString();
133
131
  return NextResponse.rewrite(
134
- new URL(
135
- `${encodeURI(Settings.commerceUrl)}/orders/redirection/${
136
- queryString ? `?${queryString}` : ''
137
- }`
138
- )
132
+ new URL(`${encodeURI(Settings.commerceUrl)}/orders/redirection/`)
139
133
  );
140
134
  }
141
135
 
@@ -239,11 +233,10 @@ const withPzDefault =
239
233
  withCompleteWallet(
240
234
  withWalletCompleteRedirection(
241
235
  withMasterpassRestCallback(
242
- withBfcacheHeaders(
243
- async (
244
- req: PzNextRequest,
245
- event: NextFetchEvent
246
- ) => {
236
+ async (
237
+ req: PzNextRequest,
238
+ event: NextFetchEvent
239
+ ) => {
247
240
  let middlewareResult: NextResponse | void =
248
241
  NextResponse.next();
249
242
 
@@ -464,7 +457,7 @@ const withPzDefault =
464
457
  }
465
458
 
466
459
  return middlewareResult;
467
- })
460
+ }
468
461
  )
469
462
  )
470
463
  )
@@ -12,7 +12,6 @@ import withSavedCardRedirection from './saved-card-redirection';
12
12
  import withCompleteWallet from './complete-wallet';
13
13
  import withWalletCompleteRedirection from './wallet-complete-redirection';
14
14
  import withMasterpassRestCallback from './masterpass-rest-callback';
15
- import withBfcacheHeaders from './bfcache-headers';
16
15
  import { NextRequest } from 'next/server';
17
16
 
18
17
  export {
@@ -29,8 +28,7 @@ export {
29
28
  withSavedCardRedirection,
30
29
  withCompleteWallet,
31
30
  withWalletCompleteRedirection,
32
- withMasterpassRestCallback,
33
- withBfcacheHeaders
31
+ withMasterpassRestCallback
34
32
  };
35
33
 
36
34
  export interface PzNextRequest extends NextRequest {
@@ -9,21 +9,49 @@ const withMasterpassRestCallback =
9
9
  async (req: PzNextRequest, event: NextFetchEvent) => {
10
10
  const url = req.nextUrl.clone();
11
11
  const ip = req.headers.get('x-forwarded-for') ?? '';
12
+ const sessionId = req.cookies.get('osessionid');
12
13
 
13
- const isMasterpassCompletePage =
14
- url.pathname.includes('/orders/checkout') &&
15
- url.searchParams.get('page') === 'MasterpassRestCompletePage';
16
-
17
- if (!isMasterpassCompletePage) {
14
+ if (!url.pathname.includes('/orders/masterpass-rest-callback')) {
18
15
  return middleware(req, event);
19
16
  }
20
17
 
21
- try {
22
- const requestUrl = new URL('/orders/checkout/', Settings.commerceUrl);
23
- url.searchParams.forEach((value, key) => {
24
- requestUrl.searchParams.set(key, value);
18
+ if (req.method !== 'POST') {
19
+ logger.warn('Invalid request method for masterpass REST callback', {
20
+ middleware: 'masterpass-rest-callback',
21
+ method: req.method,
22
+ ip
25
23
  });
26
24
 
25
+ return NextResponse.redirect(
26
+ `${url.origin}${getUrlPathWithLocale(
27
+ '/orders/checkout/',
28
+ req.cookies.get('pz-locale')?.value
29
+ )}`,
30
+ 303
31
+ );
32
+ }
33
+
34
+ const responseCode = url.searchParams.get('responseCode');
35
+ const token = url.searchParams.get('token');
36
+
37
+ if (!responseCode || !token) {
38
+ logger.warn('Missing required parameters for masterpass REST callback', {
39
+ middleware: 'masterpass-rest-callback',
40
+ responseCode,
41
+ token,
42
+ ip
43
+ });
44
+
45
+ return NextResponse.redirect(
46
+ `${url.origin}${getUrlPathWithLocale(
47
+ '/orders/checkout/',
48
+ req.cookies.get('pz-locale')?.value
49
+ )}`,
50
+ 303
51
+ );
52
+ }
53
+
54
+ try {
27
55
  const formData = await req.formData();
28
56
  const body: Record<string, string> = {};
29
57
 
@@ -31,6 +59,37 @@ const withMasterpassRestCallback =
31
59
  body[key] = value.toString();
32
60
  });
33
61
 
62
+ if (!sessionId) {
63
+ logger.warn(
64
+ 'Make sure that the SESSION_COOKIE_SAMESITE environment variable is set to None in Commerce.',
65
+ {
66
+ middleware: 'masterpass-rest-callback',
67
+ ip
68
+ }
69
+ );
70
+
71
+ return NextResponse.redirect(
72
+ `${url.origin}${getUrlPathWithLocale(
73
+ '/orders/checkout/',
74
+ req.cookies.get('pz-locale')?.value
75
+ )}`,
76
+ 303
77
+ );
78
+ }
79
+
80
+ const requestUrl = new URL('/orders/checkout/', Settings.commerceUrl);
81
+ requestUrl.searchParams.set('page', 'MasterpassRestCompletePage');
82
+ requestUrl.searchParams.set('responseCode', responseCode);
83
+ requestUrl.searchParams.set('token', token);
84
+ requestUrl.searchParams.set(
85
+ 'three_d_secure',
86
+ body.transactionType?.includes('3D') ? 'true' : 'false'
87
+ );
88
+ requestUrl.searchParams.set(
89
+ 'transactionType',
90
+ body.transactionType || ''
91
+ );
92
+
34
93
  const requestHeaders = {
35
94
  'Content-Type': 'application/x-www-form-urlencoded',
36
95
  'X-Requested-With': 'XMLHttpRequest',
@@ -46,13 +105,33 @@ const withMasterpassRestCallback =
46
105
  body: new URLSearchParams(body)
47
106
  });
48
107
 
108
+ logger.info('Masterpass REST callback request', {
109
+ requestUrl: requestUrl.toString(),
110
+ status: request.status,
111
+ requestHeaders,
112
+ ip
113
+ });
114
+
49
115
  const response = await request.json();
50
- const { errors } = response;
116
+
117
+ const { context_list: contextList, errors } = response;
118
+
119
+ let redirectUrl = response.redirect_url;
120
+
121
+ if (!redirectUrl && contextList && contextList.length > 0) {
122
+ for (const context of contextList) {
123
+ if (context.page_context && context.page_context.redirect_url) {
124
+ redirectUrl = context.page_context.redirect_url;
125
+ break;
126
+ }
127
+ }
128
+ }
51
129
 
52
130
  if (errors && Object.keys(errors).length) {
53
- logger.error('Error while processing MasterpassRestCompletePage', {
54
- middleware: 'masterpass-rest-complete',
131
+ logger.error('Error while processing masterpass REST callback', {
132
+ middleware: 'masterpass-rest-callback',
55
133
  errors,
134
+ requestHeaders,
56
135
  ip
57
136
  });
58
137
 
@@ -64,36 +143,73 @@ const withMasterpassRestCallback =
64
143
  {
65
144
  status: 303,
66
145
  headers: {
67
- 'Set-Cookie': `pz-pos-error=${encodeURIComponent(JSON.stringify(errors))}; path=/;`
146
+ 'Set-Cookie': `pz-pos-error=${JSON.stringify(errors)}; path=/;`
68
147
  }
69
148
  }
70
149
  );
71
150
  }
72
151
 
73
- const redirectUrl =
74
- response.redirect_url ||
75
- response.context_list?.[0]?.page_context?.redirect_url;
152
+ logger.info('Masterpass REST callback response', {
153
+ middleware: 'masterpass-rest-callback',
154
+ contextList,
155
+ redirectUrl,
156
+ ip
157
+ });
76
158
 
77
- if (redirectUrl) {
78
- return NextResponse.redirect(
79
- `${url.origin}${getUrlPathWithLocale(redirectUrl, req.cookies.get('pz-locale')?.value)}`,
80
- 303
159
+ if (!redirectUrl) {
160
+ logger.warn(
161
+ 'No redirection url found in response. Redirecting to checkout page.',
162
+ {
163
+ middleware: 'masterpass-rest-callback',
164
+ requestHeaders,
165
+ response: JSON.stringify(response),
166
+ ip
167
+ }
81
168
  );
169
+
170
+ const redirectUrlWithLocale = `${url.origin}${getUrlPathWithLocale(
171
+ '/orders/checkout/',
172
+ req.cookies.get('pz-locale')?.value
173
+ )}`;
174
+
175
+ return NextResponse.redirect(redirectUrlWithLocale, 303);
82
176
  }
83
177
 
84
- return NextResponse.redirect(
85
- `${url.origin}${getUrlPathWithLocale('/orders/checkout/', req.cookies.get('pz-locale')?.value)}`,
86
- 303
178
+ const redirectUrlWithLocale = `${url.origin}${getUrlPathWithLocale(
179
+ redirectUrl,
180
+ req.cookies.get('pz-locale')?.value
181
+ )}`;
182
+
183
+ logger.info('Redirecting after masterpass REST callback', {
184
+ middleware: 'masterpass-rest-callback',
185
+ redirectUrlWithLocale,
186
+ ip
187
+ });
188
+
189
+ const nextResponse = NextResponse.redirect(redirectUrlWithLocale, 303);
190
+
191
+ nextResponse.headers.set(
192
+ 'Set-Cookie',
193
+ request.headers.get('set-cookie') ?? ''
87
194
  );
195
+
196
+ return nextResponse;
88
197
  } catch (error) {
89
- logger.error('Error while processing MasterpassRestCompletePage', {
90
- middleware: 'masterpass-rest-complete',
198
+ logger.error('Error while processing masterpass REST callback', {
199
+ middleware: 'masterpass-rest-callback',
91
200
  error,
201
+ requestHeaders: {
202
+ Cookie: req.headers.get('cookie') ?? '',
203
+ 'x-currency': req.cookies.get('pz-currency')?.value ?? ''
204
+ },
92
205
  ip
93
206
  });
94
207
 
95
208
  return NextResponse.redirect(
96
- `${url.origin}${getUrlPathWithLocale('/orders/checkout/', req.cookies.get('pz-locale')?.value)}`,
209
+ `${url.origin}${getUrlPathWithLocale(
210
+ '/orders/checkout/',
211
+ req.cookies.get('pz-locale')?.value
212
+ )}`,
97
213
  303
98
214
  );
99
215
  }
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.117.0-rc.7",
4
+ "version": "1.117.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -35,7 +35,7 @@
35
35
  "set-cookie-parser": "2.6.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@akinon/eslint-plugin-projectzero": "1.117.0-rc.7",
38
+ "@akinon/eslint-plugin-projectzero": "1.117.0",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@babel/preset-typescript": "7.27.0",
package/plugins.d.ts CHANGED
@@ -37,16 +37,6 @@ declare module '@akinon/pz-cybersource-uc/src/redux/middleware' {
37
37
  export default middleware as any;
38
38
  }
39
39
 
40
- declare module '@akinon/pz-apple-pay' {}
41
-
42
- declare module '@akinon/pz-similar-products' {
43
- export const SimilarProductsModal: any;
44
- export const SimilarProductsFilterSidebar: any;
45
- export const SimilarProductsResultsGrid: any;
46
- export const SimilarProductsPlugin: any;
47
- export const SimilarProductsButtonPlugin: any;
48
- }
49
-
50
40
  declare module '@akinon/pz-cybersource-uc/src/redux/reducer' {
51
41
  export default reducer as any;
52
42
  }
package/plugins.js CHANGED
@@ -16,7 +16,6 @@ module.exports = [
16
16
  'pz-tabby-extension',
17
17
  'pz-apple-pay',
18
18
  'pz-tamara-extension',
19
- 'pz-similar-products',
20
19
  'pz-cybersource-uc',
21
20
  'pz-hepsipay',
22
21
  'pz-flow-payment',
@@ -204,25 +204,15 @@ export const contextListMiddleware: Middleware = ({
204
204
  (ctx) => ctx.page_name === 'DeliveryOptionSelectionPage'
205
205
  )
206
206
  ) {
207
- const isCreditCardPayment =
208
- preOrder?.payment_option?.payment_type === 'credit_card' ||
209
- preOrder?.payment_option?.payment_type === 'masterpass';
210
-
211
207
  if (context.page_context.card_type) {
212
208
  dispatch(setCardType(context.page_context.card_type));
213
- } else if (isCreditCardPayment) {
214
- dispatch(setCardType(null));
215
209
  }
216
210
 
217
211
  if (
218
212
  context.page_context.installments &&
219
213
  preOrder?.payment_option?.payment_type !== 'masterpass_rest'
220
214
  ) {
221
- if (!isCreditCardPayment || context.page_context.card_type) {
222
- dispatch(
223
- setInstallmentOptions(context.page_context.installments)
224
- );
225
- }
215
+ dispatch(setInstallmentOptions(context.page_context.installments));
226
216
  }
227
217
  }
228
218
 
@@ -14,17 +14,9 @@ export const installmentOptionMiddleware: Middleware = ({
14
14
  return result;
15
15
  }
16
16
 
17
- const { installmentOptions, cardType } = getState().checkout;
17
+ const { installmentOptions } = getState().checkout;
18
18
  const { endpoints: apiEndpoints } = checkoutApi;
19
19
 
20
- const isCreditCardPayment =
21
- preOrder?.payment_option?.payment_type === 'credit_card' ||
22
- preOrder?.payment_option?.payment_type === 'masterpass';
23
-
24
- if (isCreditCardPayment && !cardType) {
25
- return result;
26
- }
27
-
28
20
  if (
29
21
  !preOrder?.installment &&
30
22
  preOrder?.payment_option?.payment_type !== 'saved_card' &&
package/types/index.ts CHANGED
@@ -83,12 +83,6 @@ export interface Settings {
83
83
  };
84
84
  usePrettyUrlRoute?: boolean;
85
85
  commerceUrl: string;
86
- /**
87
- * This option allows you to track Sentry events on the client side, in addition to server and edge environments.
88
- *
89
- * It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
90
- */
91
- sentryDsn?: string;
92
86
  redis: {
93
87
  defaultExpirationTime: number;
94
88
  };
package/utils/index.ts CHANGED
@@ -193,8 +193,7 @@ export const urlLocaleMatcherRegex = new RegExp(
193
193
  );
194
194
 
195
195
  export const getPosError = () => {
196
- const cookieValue = getCookie('pz-pos-error');
197
- const error = JSON.parse(cookieValue ? decodeURIComponent(cookieValue) : '{}');
196
+ const error = JSON.parse(getCookie('pz-pos-error') ?? '{}');
198
197
 
199
198
  // delete 'pz-pos-error' cookie when refreshing or closing page
200
199
  window.addEventListener('beforeunload', () => {
@@ -1,14 +1,8 @@
1
1
  const iframeURLChange = (iframe, callback) => {
2
2
  iframe.addEventListener('load', () => {
3
3
  setTimeout(() => {
4
- try {
5
- if (iframe?.contentWindow?.location) {
6
- const iframeLocation = iframe.contentWindow.location;
7
-
8
- callback(iframeLocation);
9
- }
10
- } catch (error) {
11
- // Expected: browser blocks cross-origin iframe access for security
4
+ if (iframe?.contentWindow?.location) {
5
+ callback(iframe.contentWindow.location);
12
6
  }
13
7
  }, 0);
14
8
  });
@@ -1,14 +1,8 @@
1
1
  const iframeURLChange = (iframe, callback) => {
2
2
  iframe.addEventListener('load', () => {
3
3
  setTimeout(() => {
4
- try {
5
- if (iframe?.contentWindow?.location) {
6
- const iframeLocation = iframe.contentWindow.location;
7
-
8
- callback(iframeLocation);
9
- }
10
- } catch (error) {
11
- // Expected: browser blocks cross-origin iframe access for security
4
+ if (iframe?.contentWindow?.location) {
5
+ callback(iframe.contentWindow.location);
12
6
  }
13
7
  }, 0);
14
8
  });
package/with-pz-config.js CHANGED
@@ -9,6 +9,7 @@ const defaultConfig = {
9
9
  skipTrailingSlashRedirect: true,
10
10
  poweredByHeader: false,
11
11
  cacheMaxMemorySize: 0,
12
+ output: 'standalone',
12
13
  compress: false,
13
14
  env: {
14
15
  NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN
@@ -1,59 +0,0 @@
1
- import { NextRequest, NextResponse } from 'next/server';
2
- import Settings from 'settings';
3
-
4
- export async function GET(request: NextRequest) {
5
- try {
6
- const { searchParams } = new URL(request.url);
7
- const barcode = searchParams.get('search_text');
8
-
9
- if (!barcode) {
10
- return NextResponse.json(
11
- { error: 'Missing search_text parameter (barcode)' },
12
- { status: 400 }
13
- );
14
- }
15
-
16
- if (Settings.commerceUrl === 'default') {
17
- return NextResponse.json(
18
- { error: 'Commerce URL is not configured' },
19
- { status: 500 }
20
- );
21
- }
22
-
23
- const queryParams = new URLSearchParams();
24
- queryParams.append('search_text', barcode);
25
-
26
- searchParams.forEach((value, key) => {
27
- if (key !== 'search_text') {
28
- queryParams.append(key, value);
29
- }
30
- });
31
-
32
- const apiUrl = `${Settings.commerceUrl}/list/?${queryParams.toString()}`;
33
-
34
- const headers: Record<string, string> = {
35
- Accept: 'application/json',
36
- 'Content-Type': 'application/json'
37
- };
38
-
39
- const response = await fetch(apiUrl, {
40
- method: 'GET',
41
- headers
42
- });
43
-
44
- if (!response.ok) {
45
- return NextResponse.json(
46
- { error: `API request failed with status: ${response.status}` },
47
- { status: response.status }
48
- );
49
- }
50
-
51
- const data = await response.json();
52
- return NextResponse.json(data);
53
- } catch (error) {
54
- return NextResponse.json(
55
- { error: (error as Error).message },
56
- { status: 500 }
57
- );
58
- }
59
- }
@@ -1,18 +0,0 @@
1
- import { NextMiddleware } from 'next/server';
2
-
3
- const withBfcacheHeaders = (middleware: NextMiddleware): NextMiddleware => {
4
- return async (req, event) => {
5
- const response = await middleware(req, event);
6
-
7
- if (process.env.BF_CACHE === 'true' && response) {
8
- response.headers.set(
9
- 'Cache-Control',
10
- 'private, no-cache, max-age=0, must-revalidate'
11
- );
12
- }
13
-
14
- return response;
15
- };
16
- };
17
-
18
- export default withBfcacheHeaders;