@websolutespa/bom-mixer-models 1.7.2 → 1.7.3

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,208 +1,216 @@
1
- # @websolutespa/bom-mixer-models
2
-
3
- ## 1.7.2
4
-
5
- ### Patch Changes
6
-
7
- - Updating: dependencies
8
- - Updated dependencies
9
- - @websolutespa/bom-mixer-store@1.7.3
10
- - @websolutespa/bom-core@1.7.3
11
-
12
- ## 1.7.1
13
-
14
- ### Patch Changes
15
-
16
- - Fixing: findRoute redirects
17
-
18
- ## 1.7.0
19
-
20
- ### Minor Changes
21
-
22
- - 28e86bd: Modified: IPage, Store services & decorators
23
- - Updated dependencies [28e86bd]
24
- - @websolutespa/bom-mixer-store@1.7.0
25
- - @websolutespa/bom-core@1.7.0
26
-
27
- ## 1.6.0
28
-
29
- ### Patch Changes
30
-
31
- - f664993: Added: useLivePreview
32
- - 6707ca2: Fixing LocaleService getLocaleFromProps
33
- - Updated dependencies [f664993]
34
- - Updated dependencies [6cbf4cb]
35
- - @websolutespa/bom-mixer-store@1.4.7
36
- - @websolutespa/bom-core@0.6.7
37
-
38
- ## 1.5.10
39
-
40
- ### Patch Changes
41
-
42
- - Added: captions handler
43
-
44
- ## 1.5.9
45
-
46
- ### Patch Changes
47
-
48
- - Added: lang attribute to sitemap
49
-
50
- ## 1.5.8
51
-
52
- ### Patch Changes
53
-
54
- - Modified: getBreadcrumbFromSegments, getSeoWeight
55
- - Updated dependencies
56
- - @websolutespa/bom-core@0.6.6
57
-
58
- ## 1.5.7
59
-
60
- ### Patch Changes
61
-
62
- - Fixing: getDecoratedComponents
63
-
64
- ## 1.5.6
65
-
66
- ### Patch Changes
67
-
68
- - Added: SeoService
69
- - Modified: IFeatureType, PageService, RedirectService, RouteService
70
- - Updated dependencies
71
- - @websolutespa/bom-mixer-store@1.4.3
72
- - @websolutespa/bom-core@0.6.5
73
-
74
- ## 1.5.5
75
-
76
- ### Patch Changes
77
-
78
- - Modified: RouteInterceptor
79
-
80
- ## 1.5.4
81
-
82
- ### Patch Changes
83
-
84
- - Modified: PageService, RouteInterceptor, RouteService, StructuredData
85
- - Updated dependencies
86
- - @websolutespa/bom-mixer-store@1.4.3
87
-
88
- ## 1.5.3
89
-
90
- ### Patch Changes
91
-
92
- - Modified: RouteService
93
- - Updated dependencies
94
- - @websolutespa/bom-mixer-store@1.4.1
95
- - @websolutespa/bom-core@0.6.3
96
-
97
- ## 1.5.2
98
-
99
- ### Patch Changes
100
-
101
- - Added: StructuredData
102
- - Updated dependencies
103
- - @websolutespa/bom-core@0.6.2
104
-
105
- ## 1.5.1
106
-
107
- ### Patch Changes
108
-
109
- - Added: defaultMarket, defaultLocale
110
- - Updated dependencies [dad63747]
111
- - @websolutespa/bom-core@0.6.1
112
-
113
- ## 1.5.0
114
-
115
- ### Minor Changes
116
-
117
- - Added getDecoratedComponents, getPageProps
118
-
119
- ## 1.4.0
120
-
121
- ### Minor Changes
122
-
123
- - Modified: RouteService, LayoutService
124
-
125
- ## 1.3.0
126
-
127
- ### Minor Changes
128
-
129
- - Added: ILazyProps, ILazyableProps, ILazyedProps
130
-
131
- ## 1.2.1
132
-
133
- ### Patch Changes
134
-
135
- - Added: IAppProps, ILazyProps
136
-
137
- ## 1.2.0
138
-
139
- ### Minor Changes
140
-
141
- - Updating: next 13
142
-
143
- ## 1.1.0
144
-
145
- ### Minor Changes
146
-
147
- - Added: storeApi
148
- - Modified: SiteMapService
149
-
150
- ## 1.0.1
151
-
152
- ### Patch Changes
153
-
154
- - Added: env ROOT_CATEGORY
155
-
156
- ## 0.5.0
157
-
158
- ### Minor Changes
159
-
160
- - Modified routes, added redirects
161
-
162
- ## 0.4.2
163
-
164
- ### Patch Changes
165
-
166
- - Fixing: avoid categories circular reference
167
-
168
- ## 0.4.1
169
-
170
- ### Patch Changes
171
-
172
- - Added: source files
173
-
174
- ## 0.4.0
175
-
176
- ### Minor Changes
177
-
178
- - Added: splat routes
179
-
180
- ## 0.3.0
181
-
182
- ### Minor Changes
183
-
184
- - Added: @websolutespa/bom-core
185
-
186
- ## 0.2.0
187
-
188
- ### Minor Changes
189
-
190
- - Added: LazyComponent Types
191
-
192
- ## 0.1.1
193
-
194
- ### Patch Changes
195
-
196
- - Modified: page service
197
-
198
- ## 0.1.0
199
-
200
- ### Minor Changes
201
-
202
- - mock refactor
203
-
204
- ## 0.0.2
205
-
206
- ### Patch Changes
207
-
208
- - Added: first release
1
+ # @websolutespa/bom-mixer-models
2
+
3
+ ## 1.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: getOrigin, getHost
8
+ - Updated dependencies
9
+ - @websolutespa/bom-core@1.7.4
10
+
11
+ ## 1.7.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updating: dependencies
16
+ - Updated dependencies
17
+ - @websolutespa/bom-mixer-store@1.7.3
18
+ - @websolutespa/bom-core@1.7.3
19
+
20
+ ## 1.7.1
21
+
22
+ ### Patch Changes
23
+
24
+ - Fixing: findRoute redirects
25
+
26
+ ## 1.7.0
27
+
28
+ ### Minor Changes
29
+
30
+ - 28e86bd: Modified: IPage, Store services & decorators
31
+ - Updated dependencies [28e86bd]
32
+ - @websolutespa/bom-mixer-store@1.7.0
33
+ - @websolutespa/bom-core@1.7.0
34
+
35
+ ## 1.6.0
36
+
37
+ ### Patch Changes
38
+
39
+ - f664993: Added: useLivePreview
40
+ - 6707ca2: Fixing LocaleService getLocaleFromProps
41
+ - Updated dependencies [f664993]
42
+ - Updated dependencies [6cbf4cb]
43
+ - @websolutespa/bom-mixer-store@1.4.7
44
+ - @websolutespa/bom-core@0.6.7
45
+
46
+ ## 1.5.10
47
+
48
+ ### Patch Changes
49
+
50
+ - Added: captions handler
51
+
52
+ ## 1.5.9
53
+
54
+ ### Patch Changes
55
+
56
+ - Added: lang attribute to sitemap
57
+
58
+ ## 1.5.8
59
+
60
+ ### Patch Changes
61
+
62
+ - Modified: getBreadcrumbFromSegments, getSeoWeight
63
+ - Updated dependencies
64
+ - @websolutespa/bom-core@0.6.6
65
+
66
+ ## 1.5.7
67
+
68
+ ### Patch Changes
69
+
70
+ - Fixing: getDecoratedComponents
71
+
72
+ ## 1.5.6
73
+
74
+ ### Patch Changes
75
+
76
+ - Added: SeoService
77
+ - Modified: IFeatureType, PageService, RedirectService, RouteService
78
+ - Updated dependencies
79
+ - @websolutespa/bom-mixer-store@1.4.3
80
+ - @websolutespa/bom-core@0.6.5
81
+
82
+ ## 1.5.5
83
+
84
+ ### Patch Changes
85
+
86
+ - Modified: RouteInterceptor
87
+
88
+ ## 1.5.4
89
+
90
+ ### Patch Changes
91
+
92
+ - Modified: PageService, RouteInterceptor, RouteService, StructuredData
93
+ - Updated dependencies
94
+ - @websolutespa/bom-mixer-store@1.4.3
95
+
96
+ ## 1.5.3
97
+
98
+ ### Patch Changes
99
+
100
+ - Modified: RouteService
101
+ - Updated dependencies
102
+ - @websolutespa/bom-mixer-store@1.4.1
103
+ - @websolutespa/bom-core@0.6.3
104
+
105
+ ## 1.5.2
106
+
107
+ ### Patch Changes
108
+
109
+ - Added: StructuredData
110
+ - Updated dependencies
111
+ - @websolutespa/bom-core@0.6.2
112
+
113
+ ## 1.5.1
114
+
115
+ ### Patch Changes
116
+
117
+ - Added: defaultMarket, defaultLocale
118
+ - Updated dependencies [dad63747]
119
+ - @websolutespa/bom-core@0.6.1
120
+
121
+ ## 1.5.0
122
+
123
+ ### Minor Changes
124
+
125
+ - Added getDecoratedComponents, getPageProps
126
+
127
+ ## 1.4.0
128
+
129
+ ### Minor Changes
130
+
131
+ - Modified: RouteService, LayoutService
132
+
133
+ ## 1.3.0
134
+
135
+ ### Minor Changes
136
+
137
+ - Added: ILazyProps, ILazyableProps, ILazyedProps
138
+
139
+ ## 1.2.1
140
+
141
+ ### Patch Changes
142
+
143
+ - Added: IAppProps, ILazyProps
144
+
145
+ ## 1.2.0
146
+
147
+ ### Minor Changes
148
+
149
+ - Updating: next 13
150
+
151
+ ## 1.1.0
152
+
153
+ ### Minor Changes
154
+
155
+ - Added: storeApi
156
+ - Modified: SiteMapService
157
+
158
+ ## 1.0.1
159
+
160
+ ### Patch Changes
161
+
162
+ - Added: env ROOT_CATEGORY
163
+
164
+ ## 0.5.0
165
+
166
+ ### Minor Changes
167
+
168
+ - Modified routes, added redirects
169
+
170
+ ## 0.4.2
171
+
172
+ ### Patch Changes
173
+
174
+ - Fixing: avoid categories circular reference
175
+
176
+ ## 0.4.1
177
+
178
+ ### Patch Changes
179
+
180
+ - Added: source files
181
+
182
+ ## 0.4.0
183
+
184
+ ### Minor Changes
185
+
186
+ - Added: splat routes
187
+
188
+ ## 0.3.0
189
+
190
+ ### Minor Changes
191
+
192
+ - Added: @websolutespa/bom-core
193
+
194
+ ## 0.2.0
195
+
196
+ ### Minor Changes
197
+
198
+ - Added: LazyComponent Types
199
+
200
+ ## 0.1.1
201
+
202
+ ### Patch Changes
203
+
204
+ - Modified: page service
205
+
206
+ ## 0.1.0
207
+
208
+ ### Minor Changes
209
+
210
+ - mock refactor
211
+
212
+ ## 0.0.2
213
+
214
+ ### Patch Changes
215
+
216
+ - Added: first release
package/dist/index.d.ts CHANGED
@@ -286,7 +286,7 @@ declare function getErrorPageLayout(): Promise<{
286
286
  }>;
287
287
  type PartialPageProps<T extends ICategorized, B> = Omit<PageProps<T>, 'page'> & Partial<Pick<PageProps<T>, 'page'>> & B;
288
288
  declare function getPageProps<T extends ICategorized, B = any>(props: PartialPageProps<T, B>): Promise<PageProps<T> & B>;
289
- declare function getOrigin(): string;
289
+ declare function getPublicUrl(): string;
290
290
  declare function resolveHref(href?: string): string;
291
291
 
292
292
  declare const getPreviewProps: GetServerSideProps;
@@ -430,4 +430,4 @@ type StructuredDataKeys = 'article';
430
430
  type StructuredDataCollections = Record<StructuredDataKeys, string[]>;
431
431
  declare function resolveStructuredData(page: IPage, types?: StructuredDataCollections): string | undefined;
432
432
 
433
- export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore, ICompanyAddress, IFeatureType, IKeyedList, ILazyComponent, ILazyComponentFunc, ILazyComponentProps, ILazyFuncProps, ILazyModules, ILazyProps, ILazyStaticProps, ILazyStaticPropsFunc, ILazyableProps, ILazyedProps, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, LAZY_PROPS, NotFound, PartialPageProps, SeoWeight, StaticPath, StructuredDataAddress, StructuredDataArticle, StructuredDataCollections, StructuredDataEvent, StructuredDataKeys, StructuredDataOffer, StructuredDataOrganization, StructuredDataPerformingGroup, StructuredDataPerson, StructuredDataPlace, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCaptionsVttProps, getCategories, getCategory, getCountries, getCountry, getDecoratedComponents, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getOrigin, getPage, getPageCategory, getPageProps, getPageRoutes, getPayment, getPayments, getPreviewProps, getProvince, getProvinces, getRedirect, getRedirects, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSeoWeight, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, newRouteLink, redirectTo, resolveHref, resolveLabel, resolveRoute, resolveStructuredData, routeInterceptor, routeRevalidateHandler, routeToRouteLink, setDiscountCode, updateCheckout, withLazyProps };
433
+ export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore, ICompanyAddress, IFeatureType, IKeyedList, ILazyComponent, ILazyComponentFunc, ILazyComponentProps, ILazyFuncProps, ILazyModules, ILazyProps, ILazyStaticProps, ILazyStaticPropsFunc, ILazyableProps, ILazyedProps, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, LAZY_PROPS, NotFound, PartialPageProps, SeoWeight, StaticPath, StructuredDataAddress, StructuredDataArticle, StructuredDataCollections, StructuredDataEvent, StructuredDataKeys, StructuredDataOffer, StructuredDataOrganization, StructuredDataPerformingGroup, StructuredDataPerson, StructuredDataPlace, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCaptionsVttProps, getCategories, getCategory, getCountries, getCountry, getDecoratedComponents, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getPage, getPageCategory, getPageProps, getPageRoutes, getPayment, getPayments, getPreviewProps, getProvince, getProvinces, getPublicUrl, getRedirect, getRedirects, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSeoWeight, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, newRouteLink, redirectTo, resolveHref, resolveLabel, resolveRoute, resolveStructuredData, routeInterceptor, routeRevalidateHandler, routeToRouteLink, setDiscountCode, updateCheckout, withLazyProps };
package/dist/index.js CHANGED
@@ -53,7 +53,6 @@ __export(src_exports, {
53
53
  getMenus: () => getMenus,
54
54
  getOrder: () => getOrder,
55
55
  getOrders: () => getOrders,
56
- getOrigin: () => getOrigin,
57
56
  getPage: () => getPage,
58
57
  getPageCategory: () => getPageCategory,
59
58
  getPageProps: () => getPageProps,
@@ -63,6 +62,7 @@ __export(src_exports, {
63
62
  getPreviewProps: () => getPreviewProps,
64
63
  getProvince: () => getProvince,
65
64
  getProvinces: () => getProvinces,
65
+ getPublicUrl: () => getPublicUrl,
66
66
  getRedirect: () => getRedirect,
67
67
  getRedirects: () => getRedirects,
68
68
  getRegion: () => getRegion,
@@ -1300,12 +1300,12 @@ async function getPageProps(props) {
1300
1300
  }
1301
1301
  return (0, import_bom_core3.asServerProps)(props);
1302
1302
  }
1303
- function getOrigin() {
1304
- const origin = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1305
- return origin;
1303
+ function getPublicUrl() {
1304
+ const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1305
+ return publicUrl;
1306
1306
  }
1307
1307
  function resolveHref(href = "") {
1308
- return href.startsWith("http") ? href : `${getOrigin()}${href}`;
1308
+ return href.startsWith("http") ? href : `${getPublicUrl()}${href}`;
1309
1309
  }
1310
1310
 
1311
1311
  // src/preview/preview.handler.ts
@@ -1370,6 +1370,7 @@ function routeRevalidateHandler() {
1370
1370
  }
1371
1371
 
1372
1372
  // src/route/route.interceptor.ts
1373
+ var import_bom_core4 = require("@websolutespa/bom-core");
1373
1374
  var import_bom_mixer_store16 = require("@websolutespa/bom-mixer-store");
1374
1375
  var import_server = require("next/server");
1375
1376
  async function routeInterceptor(request, next) {
@@ -1412,8 +1413,8 @@ async function routeInterceptor(request, next) {
1412
1413
  function getHrefBeforeRedirect(request) {
1413
1414
  let hrefBeforeRedirect = null;
1414
1415
  const urlBeforeRedirect = request.nextUrl.clone();
1415
- const host = request.headers.get("host");
1416
- if (typeof host === "string") {
1416
+ const host = (0, import_bom_core4.getHost)(request.headers);
1417
+ if (host) {
1417
1418
  urlBeforeRedirect.host = host;
1418
1419
  urlBeforeRedirect.port = host.split(":")[1] || "";
1419
1420
  hrefBeforeRedirect = urlBeforeRedirect.href;
@@ -1430,8 +1431,11 @@ var getSeoWeight = (index = 0, seoWeight) => {
1430
1431
  return getter;
1431
1432
  };
1432
1433
 
1434
+ // src/sitemap/sitemap.handler.ts
1435
+ var import_bom_core6 = require("@websolutespa/bom-core");
1436
+
1433
1437
  // src/sitemap/sitemap.service.ts
1434
- var import_bom_core4 = require("@websolutespa/bom-core");
1438
+ var import_bom_core5 = require("@websolutespa/bom-core");
1435
1439
  async function getSiteMapIndex(origin) {
1436
1440
  let markets = await getMarkets();
1437
1441
  let locales = await getLocales();
@@ -1442,7 +1446,7 @@ async function getSiteMapIndex(origin) {
1442
1446
  const getTime = (date) => {
1443
1447
  return typeof date !== "undefined" ? (typeof date === "string" ? new Date(date) : date).getTime() : 0;
1444
1448
  };
1445
- (0, import_bom_core4.eachMarketLocale)(markets, locales, (market, locale, markets2, locales2) => {
1449
+ (0, import_bom_core5.eachMarketLocale)(markets, locales, (market, locale, markets2, locales2) => {
1446
1450
  const sitemapRoutes = routes.filter((x) => x.market === market.id && x.locale === locale.id);
1447
1451
  sitemapRoutes.sort((a, b) => getTime(a.updatedAt) - getTime(b.updatedAt));
1448
1452
  sitemaps.push({
@@ -1687,17 +1691,9 @@ async function getSiteMapXSL(localeId) {
1687
1691
  }
1688
1692
 
1689
1693
  // src/sitemap/sitemap.handler.ts
1690
- var ORIGIN = process.env.NEXT_PUBLIC_URL || "";
1691
- function getOrigin2(host) {
1692
- if (host) {
1693
- return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
1694
- } else {
1695
- return ORIGIN;
1696
- }
1697
- }
1698
1694
  var getSiteMapIndexProps = async (context) => {
1699
1695
  const { req, res } = context;
1700
- const sitemap = await getSiteMapIndex(getOrigin2(req.headers.host));
1696
+ const sitemap = await getSiteMapIndex((0, import_bom_core6.getOrigin)(req.headers));
1701
1697
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1702
1698
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1703
1699
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1712,7 +1708,7 @@ var getSiteMapXMLProps = async (context) => {
1712
1708
  const params = context.params;
1713
1709
  const market = params?.market;
1714
1710
  const locale = params?.locale;
1715
- const sitemap = await getSiteMapXML(getOrigin2(req.headers.host), market, locale);
1711
+ const sitemap = await getSiteMapXML((0, import_bom_core6.getOrigin)(req.headers), market, locale);
1716
1712
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1717
1713
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1718
1714
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1802,7 +1798,6 @@ function resolveStructuredData(page, types = DefaultStructuredDataCollections) {
1802
1798
  getMenus,
1803
1799
  getOrder,
1804
1800
  getOrders,
1805
- getOrigin,
1806
1801
  getPage,
1807
1802
  getPageCategory,
1808
1803
  getPageProps,
@@ -1812,6 +1807,7 @@ function resolveStructuredData(page, types = DefaultStructuredDataCollections) {
1812
1807
  getPreviewProps,
1813
1808
  getProvince,
1814
1809
  getProvinces,
1810
+ getPublicUrl,
1815
1811
  getRedirect,
1816
1812
  getRedirects,
1817
1813
  getRegion,
package/dist/index.mjs CHANGED
@@ -1201,12 +1201,12 @@ async function getPageProps(props) {
1201
1201
  }
1202
1202
  return asServerProps(props);
1203
1203
  }
1204
- function getOrigin() {
1205
- const origin = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1206
- return origin;
1204
+ function getPublicUrl() {
1205
+ const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1206
+ return publicUrl;
1207
1207
  }
1208
1208
  function resolveHref(href = "") {
1209
- return href.startsWith("http") ? href : `${getOrigin()}${href}`;
1209
+ return href.startsWith("http") ? href : `${getPublicUrl()}${href}`;
1210
1210
  }
1211
1211
 
1212
1212
  // src/preview/preview.handler.ts
@@ -1271,6 +1271,7 @@ function routeRevalidateHandler() {
1271
1271
  }
1272
1272
 
1273
1273
  // src/route/route.interceptor.ts
1274
+ import { getHost } from "@websolutespa/bom-core";
1274
1275
  import { StoreStrategy, localApiPost, storeApiPost, storeStrategy } from "@websolutespa/bom-mixer-store";
1275
1276
  import { NextResponse } from "next/server";
1276
1277
  async function routeInterceptor(request, next) {
@@ -1313,8 +1314,8 @@ async function routeInterceptor(request, next) {
1313
1314
  function getHrefBeforeRedirect(request) {
1314
1315
  let hrefBeforeRedirect = null;
1315
1316
  const urlBeforeRedirect = request.nextUrl.clone();
1316
- const host = request.headers.get("host");
1317
- if (typeof host === "string") {
1317
+ const host = getHost(request.headers);
1318
+ if (host) {
1318
1319
  urlBeforeRedirect.host = host;
1319
1320
  urlBeforeRedirect.port = host.split(":")[1] || "";
1320
1321
  hrefBeforeRedirect = urlBeforeRedirect.href;
@@ -1331,6 +1332,9 @@ var getSeoWeight = (index = 0, seoWeight) => {
1331
1332
  return getter;
1332
1333
  };
1333
1334
 
1335
+ // src/sitemap/sitemap.handler.ts
1336
+ import { getOrigin } from "@websolutespa/bom-core";
1337
+
1334
1338
  // src/sitemap/sitemap.service.ts
1335
1339
  import { eachMarketLocale } from "@websolutespa/bom-core";
1336
1340
  async function getSiteMapIndex(origin) {
@@ -1588,17 +1592,9 @@ async function getSiteMapXSL(localeId) {
1588
1592
  }
1589
1593
 
1590
1594
  // src/sitemap/sitemap.handler.ts
1591
- var ORIGIN = process.env.NEXT_PUBLIC_URL || "";
1592
- function getOrigin2(host) {
1593
- if (host) {
1594
- return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
1595
- } else {
1596
- return ORIGIN;
1597
- }
1598
- }
1599
1595
  var getSiteMapIndexProps = async (context) => {
1600
1596
  const { req, res } = context;
1601
- const sitemap = await getSiteMapIndex(getOrigin2(req.headers.host));
1597
+ const sitemap = await getSiteMapIndex(getOrigin(req.headers));
1602
1598
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1603
1599
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1604
1600
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1613,7 +1609,7 @@ var getSiteMapXMLProps = async (context) => {
1613
1609
  const params = context.params;
1614
1610
  const market = params?.market;
1615
1611
  const locale = params?.locale;
1616
- const sitemap = await getSiteMapXML(getOrigin2(req.headers.host), market, locale);
1612
+ const sitemap = await getSiteMapXML(getOrigin(req.headers), market, locale);
1617
1613
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1618
1614
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1619
1615
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1702,7 +1698,6 @@ export {
1702
1698
  getMenus,
1703
1699
  getOrder,
1704
1700
  getOrders,
1705
- getOrigin,
1706
1701
  getPage,
1707
1702
  getPageCategory,
1708
1703
  getPageProps,
@@ -1712,6 +1707,7 @@ export {
1712
1707
  getPreviewProps,
1713
1708
  getProvince,
1714
1709
  getProvinces,
1710
+ getPublicUrl,
1715
1711
  getRedirect,
1716
1712
  getRedirects,
1717
1713
  getRegion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-models",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Mixer Models module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -198,11 +198,11 @@ export async function getPageProps<T extends ICategorized, B = any>(props: Parti
198
198
  return asServerProps(props) as PageProps<T> & B;
199
199
  }
200
200
 
201
- export function getOrigin() {
202
- const origin = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : '';
203
- return origin;
201
+ export function getPublicUrl() {
202
+ const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : '';
203
+ return publicUrl;
204
204
  }
205
205
 
206
206
  export function resolveHref(href: string = '') {
207
- return href.startsWith('http') ? href : `${getOrigin()}${href}`;
207
+ return href.startsWith('http') ? href : `${getPublicUrl()}${href}`;
208
208
  }
@@ -1,4 +1,4 @@
1
- import { IRoute } from '@websolutespa/bom-core';
1
+ import { IRoute, getHost } from '@websolutespa/bom-core';
2
2
  import { StoreStrategy, localApiPost, storeApiPost, storeStrategy } from '@websolutespa/bom-mixer-store';
3
3
  import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
4
4
  import { resolveRoute } from './route.service';
@@ -51,17 +51,11 @@ export async function routeInterceptor(request: NextRequest, next: NextFetchEven
51
51
  function getHrefBeforeRedirect(request: NextRequest): string | null {
52
52
  let hrefBeforeRedirect: string | null = null;
53
53
  const urlBeforeRedirect = request.nextUrl.clone();
54
- const host = request.headers.get('host');
55
- if (typeof host === 'string') {
54
+ const host = getHost(request.headers);
55
+ if (host) {
56
56
  urlBeforeRedirect.host = host;
57
57
  urlBeforeRedirect.port = host.split(':')[1] || '';
58
58
  hrefBeforeRedirect = urlBeforeRedirect.href;
59
59
  }
60
- /*
61
- console.log('urlBeforeRedirect', urlBeforeRedirect.href);
62
- console.log('url', request.url);
63
- console.log('nextUrl', request.nextUrl.href, 'origin', request.nextUrl.origin);
64
- console.log('host', request.headers.get('host'), 'referer', request.headers.get('referer'));
65
- */
66
60
  return hrefBeforeRedirect;
67
61
  }
@@ -1,21 +1,11 @@
1
- import { IContextParams } from '@websolutespa/bom-core';
1
+ import { IContextParams, getOrigin } from '@websolutespa/bom-core';
2
2
  import { GetServerSideProps } from 'next';
3
3
  import { getSiteMapIndex, getSiteMapXML, getSiteMapXSL } from './sitemap.service';
4
4
 
5
- const ORIGIN = process.env.NEXT_PUBLIC_URL || '';
6
-
7
- function getOrigin(host?: string): string {
8
- if (host) {
9
- return host.indexOf('localhost') !== -1 ? 'http://' + host : 'https://' + host;
10
- } else {
11
- return ORIGIN;
12
- }
13
- }
14
-
15
5
  export const getSiteMapIndexProps: GetServerSideProps = async (context) => {
16
6
  const { req, res } = context;
17
7
  // console.log('getSiteMapIndexProps', req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
18
- const sitemap = await getSiteMapIndex(getOrigin(req.headers.host));
8
+ const sitemap = await getSiteMapIndex(getOrigin(req.headers));
19
9
  res.setHeader('Content-Type', 'application/xml; charset=UTF-8');
20
10
  res.setHeader('X-Frame-Options', 'SAMEORIGIN');
21
11
  res.setHeader('X-Robots-Tag', 'noindex, follow');
@@ -32,7 +22,7 @@ export const getSiteMapXMLProps: GetServerSideProps = async (context) => {
32
22
  const params = context.params as IContextParams;
33
23
  const market = params?.market;
34
24
  const locale = params?.locale;
35
- const sitemap = await getSiteMapXML(getOrigin(req.headers.host), market, locale);
25
+ const sitemap = await getSiteMapXML(getOrigin(req.headers), market, locale);
36
26
  res.setHeader('Content-Type', 'application/xml; charset=UTF-8');
37
27
  res.setHeader('X-Frame-Options', 'SAMEORIGIN');
38
28
  res.setHeader('X-Robots-Tag', 'noindex, follow');