@akinon/next 1.103.0-snapshot-ZERO-3648-20251002143850 → 1.103.0-snapshot-ZERO-3648-20251002184136

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,6 +1,6 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.103.0-snapshot-ZERO-3648-20251002143850
3
+ ## 1.103.0-snapshot-ZERO-3648-20251002184136
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -1,4 +1,5 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
+ import Settings from 'settings';
2
3
 
3
4
  const VIRTUAL_TRY_ON_API_URL = process.env.NEXT_PUBLIC_VIRTUAL_TRY_ON_API_URL;
4
5
 
@@ -34,14 +35,20 @@ function getClientIP(request: NextRequest): string | null {
34
35
  return null;
35
36
  }
36
37
 
37
- function getLocaleFromRequest(request: NextRequest): string {
38
+ function getLocaleFromRequest(request: NextRequest): string | null {
38
39
  const referer = request.headers.get('referer') || '';
39
40
  const localeMatch = referer.match(/\/(\w{2})[-/]/);
40
- return localeMatch ? localeMatch[1] : 'en';
41
- }
42
41
 
43
- function getAcceptLanguageHeader(locale: string): string {
44
- return `${locale}-${locale.toUpperCase()},${locale};q=0.9`;
42
+ if (!localeMatch) {
43
+ return null;
44
+ }
45
+
46
+ const localeValue = localeMatch[1];
47
+ const currentLocale = Settings.localization.locales.find(
48
+ (l) => l.value === localeValue
49
+ );
50
+
51
+ return currentLocale?.apiValue || null;
45
52
  }
46
53
 
47
54
  export async function GET(request: NextRequest) {
@@ -73,11 +80,10 @@ export async function GET(request: NextRequest) {
73
80
  const externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/limited-categories`;
74
81
  const clientIP = getClientIP(request);
75
82
  const locale = getLocaleFromRequest(request);
76
- const acceptLanguage = getAcceptLanguageHeader(locale);
77
83
 
78
84
  const headersToSend = {
79
85
  Accept: 'application/json',
80
- 'Accept-Language': acceptLanguage,
86
+ ...(locale && { 'Accept-Language': locale }),
81
87
  ...(request.headers.get('authorization') && {
82
88
  Authorization: request.headers.get('authorization')!
83
89
  }),
@@ -147,11 +153,10 @@ export async function POST(request: NextRequest) {
147
153
  const httpMethod = endpoint === 'feedback' ? 'PUT' : 'POST';
148
154
  const clientIP = getClientIP(request);
149
155
  const locale = getLocaleFromRequest(request);
150
- const acceptLanguage = getAcceptLanguageHeader(locale);
151
156
 
152
157
  const headersToSend = {
153
158
  'Content-Type': 'application/json',
154
- 'Accept-Language': acceptLanguage,
159
+ ...(locale && { 'Accept-Language': locale }),
155
160
  ...(httpMethod === 'POST' && { Accept: 'application/json' }),
156
161
  ...(request.headers.get('authorization') && {
157
162
  Authorization: request.headers.get('authorization')!
@@ -253,11 +258,10 @@ export async function PUT(request: NextRequest) {
253
258
  const externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
254
259
  const clientIP = getClientIP(request);
255
260
  const locale = getLocaleFromRequest(request);
256
- const acceptLanguage = getAcceptLanguageHeader(locale);
257
261
 
258
262
  const headersToSend = {
259
263
  'Content-Type': 'application/json',
260
- 'Accept-Language': acceptLanguage,
264
+ ...(locale && { 'Accept-Language': locale }),
261
265
  ...(request.headers.get('authorization') && {
262
266
  Authorization: request.headers.get('authorization')!
263
267
  }),
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.103.0-snapshot-ZERO-3648-20251002143850",
4
+ "version": "1.103.0-snapshot-ZERO-3648-20251002184136",
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.103.0-snapshot-ZERO-3648-20251002143850",
38
+ "@akinon/eslint-plugin-projectzero": "1.103.0-snapshot-ZERO-3648-20251002184136",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@babel/preset-typescript": "7.27.0",