@amboras-dev/storefront-core 2026.11.11 → 2026.11.12-rc.1
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 +130 -0
- package/README.md +29 -3
- package/bin/amboras-check.mjs +2 -1
- package/bin/checks/check-market-routes.mjs +184 -0
- package/bin/checks/check-redirect-boundaries.mjs +10 -2
- package/core-manifest.json +6 -1
- package/dist/edge/hosted-checkout.d.ts +5 -2
- package/dist/edge/hosted-checkout.d.ts.map +1 -1
- package/dist/edge/hosted-checkout.js +11 -7
- package/dist/edge/hosted-checkout.js.map +1 -1
- package/dist/edge/market.d.ts +45 -0
- package/dist/edge/market.d.ts.map +1 -0
- package/dist/edge/market.js +74 -0
- package/dist/edge/market.js.map +1 -0
- package/dist/edge/proxy.d.ts +27 -2
- package/dist/edge/proxy.d.ts.map +1 -1
- package/dist/edge/proxy.js +206 -56
- package/dist/edge/proxy.js.map +1 -1
- package/dist/edge/url-map.d.ts +57 -0
- package/dist/edge/url-map.d.ts.map +1 -0
- package/dist/edge/url-map.js +140 -0
- package/dist/edge/url-map.js.map +1 -0
- package/dist/hooks/use-auth.d.ts.map +1 -1
- package/dist/hooks/use-auth.js +5 -2
- package/dist/hooks/use-auth.js.map +1 -1
- package/dist/lib/market.d.ts +176 -0
- package/dist/lib/market.d.ts.map +1 -0
- package/dist/lib/market.js +228 -0
- package/dist/lib/market.js.map +1 -0
- package/dist/lib/medusa-client.d.ts.map +1 -1
- package/dist/lib/medusa-client.js +30 -1
- package/dist/lib/medusa-client.js.map +1 -1
- package/dist/lib/redirects.d.ts +14 -6
- package/dist/lib/redirects.d.ts.map +1 -1
- package/dist/lib/redirects.js +68 -9
- package/dist/lib/redirects.js.map +1 -1
- package/dist/lib/seo.d.ts +20 -7
- package/dist/lib/seo.d.ts.map +1 -1
- package/dist/lib/seo.js +185 -33
- package/dist/lib/seo.js.map +1 -1
- package/dist/lib/site-url.d.ts +24 -0
- package/dist/lib/site-url.d.ts.map +1 -1
- package/dist/lib/site-url.js +35 -0
- package/dist/lib/site-url.js.map +1 -1
- package/dist/lib/visitor-free-routes.d.ts +18 -0
- package/dist/lib/visitor-free-routes.d.ts.map +1 -0
- package/dist/lib/visitor-free-routes.js +33 -0
- package/dist/lib/visitor-free-routes.js.map +1 -0
- package/dist/next-config/index.d.ts +31 -0
- package/dist/next-config/index.d.ts.map +1 -1
- package/dist/next-config/index.js +32 -1
- package/dist/next-config/index.js.map +1 -1
- package/dist/shell/market-link.d.ts +18 -0
- package/dist/shell/market-link.d.ts.map +1 -0
- package/dist/shell/market-link.js +39 -0
- package/dist/shell/market-link.js.map +1 -0
- package/package.json +5 -1
package/dist/lib/seo.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { headers } from 'next/headers';
|
|
1
2
|
import { connection } from 'next/server';
|
|
2
3
|
import { logger } from './logger.js';
|
|
4
|
+
import { getStoreUrlMap, isAnnounced, isMarketTreeBuild, keyOfPresence, presenceOfHost, TEMPLATE_PRIVATE_PATHS as DISALLOWED_PATHS, } from './market.js';
|
|
3
5
|
import { collectionPath, productPath } from './paths.js';
|
|
4
|
-
import { siteMetadataBase } from './site-url.js';
|
|
6
|
+
import { marketMetadataBase, requestHostOf, siteMetadataBase } from './site-url.js';
|
|
5
7
|
import { storeGetJsonStrict } from './store-api.js';
|
|
6
|
-
const DISALLOWED_PATHS = ['/cart', '/checkout', '/account', '/auth', '/search', '/kit-gallery'];
|
|
7
8
|
/**
|
|
8
9
|
* A Vercel preview or development deploy (a draft, an A/B variant) is not for search engines: no
|
|
9
10
|
* sitemap and a blanket `Disallow`. Unset `VERCEL_ENV` (local dev, a non-Vercel host) is not a preview.
|
|
@@ -30,37 +31,162 @@ const REVALIDATE_SECONDS = 3600;
|
|
|
30
31
|
/** Where the store's `app/sitemaps/sitemap.ts` serves the children (`<dir>/sitemap/<id>.xml`). */
|
|
31
32
|
const SITEMAP_CHILDREN_PATH = '/sitemaps/sitemap';
|
|
32
33
|
const LIST_FIELDS = 'handle,updated_at';
|
|
34
|
+
/** A market product page also reads `id`, which tells which other markets sell each product (`soldIn`). */
|
|
35
|
+
const MARKET_LIST_FIELDS = 'id,handle,updated_at';
|
|
33
36
|
/**
|
|
34
|
-
*
|
|
37
|
+
* A child id is `slot * IDS_PER_MARKET + page`: slot 0 is the root (today's ids, unchanged), then one slot per
|
|
38
|
+
* announced subfolder market (AMB-2174); page 0 is the static pages and collections, page n products page n.
|
|
39
|
+
* ponytail: 100 000 pages (25M products) per market before ids collide; widen the stride if a store ever nears it.
|
|
40
|
+
*/
|
|
41
|
+
const IDS_PER_MARKET = 100_000;
|
|
42
|
+
/**
|
|
43
|
+
* A sitemap's read of a store route, cached per URL by Next and bounded by the store read timeout
|
|
35
44
|
* (`storeGetJsonStrict`). Unlike `storeGetJson` it rejects on any failure, a timeout included, so the route
|
|
36
45
|
* answers 5xx (which crawlers retry) instead of serving a partial sitemap, and Next never caches a failure.
|
|
37
46
|
*/
|
|
47
|
+
async function sitemapRead(route, query = '') {
|
|
48
|
+
const result = await storeGetJsonStrict(`${route}${query && `?${query}`}`, { revalidate: REVALIDATE_SECONDS });
|
|
49
|
+
if (result.kind !== 'ok')
|
|
50
|
+
throw new Error(`Medusa ${route} failed: ${result.kind === 'failure' ? result.reason : `no usable answer (HTTP ${result.status})`}`);
|
|
51
|
+
return result.data;
|
|
52
|
+
}
|
|
53
|
+
/** One page of `/store/<resource>` (`sitemapRead`). */
|
|
38
54
|
async function listPage(resource, query) {
|
|
39
55
|
const params = new URLSearchParams(Object.entries(query).map(([key, value]) => [key, String(value)]));
|
|
40
|
-
const
|
|
41
|
-
if (result.kind !== 'ok')
|
|
42
|
-
throw new Error(`Medusa /store/${resource} failed: ${result.kind === 'failure' ? result.reason : `no usable answer (HTTP ${result.status})`}`);
|
|
43
|
-
const { data } = result;
|
|
56
|
+
const data = await sitemapRead(`/store/${resource}`, params.toString());
|
|
44
57
|
return { items: data[resource] ?? [], count: data.count ?? 0, limit: data.limit };
|
|
45
58
|
}
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The URL Next's canonical gives `path` under a `metadataBase`: `https://store.com/x` on an origin, and
|
|
61
|
+
* `https://store.com/en-ca/x` under a market's (the market home without a trailing slash).
|
|
62
|
+
*/
|
|
63
|
+
function pageUrl(base, path) {
|
|
64
|
+
return base.pathname === '/' ? new URL(path, base).href : base.origin + base.pathname + (path === '/' ? '' : path);
|
|
48
65
|
}
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
function entry(base, path, updatedAt, languages) {
|
|
67
|
+
const alternates = languages?.(path);
|
|
68
|
+
return {
|
|
69
|
+
url: pageUrl(base, path),
|
|
70
|
+
...(updatedAt ? { lastModified: updatedAt } : {}),
|
|
71
|
+
...(alternates ? { alternates: { languages: alternates } } : {}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Child 0: the static pages, then every collection with a handle. `base` may be a market's (`marketMetadataBase`). */
|
|
75
|
+
export function buildPagesSitemap(base, collections, staticPaths, languages) {
|
|
51
76
|
return [
|
|
52
|
-
...staticPaths.map((path) => entry(base, path)),
|
|
53
|
-
...collections.flatMap((c) => (c.handle ? [entry(base, collectionPath(c.handle), c.updated_at)] : [])),
|
|
77
|
+
...staticPaths.map((path) => entry(base, path, undefined, languages)),
|
|
78
|
+
...collections.flatMap((c) => (c.handle ? [entry(base, collectionPath(c.handle), c.updated_at, languages)] : [])),
|
|
54
79
|
];
|
|
55
80
|
}
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Children 1..N: the products of one page that have a handle. `soldIn(product)`, when given, is whether a market
|
|
83
|
+
* sells that product: its alternates name only those markets.
|
|
84
|
+
*/
|
|
85
|
+
export function buildProductsSitemap(base, products, languages, soldIn) {
|
|
86
|
+
return products.flatMap((p) => {
|
|
87
|
+
if (!p.handle)
|
|
88
|
+
return [];
|
|
89
|
+
const own = languages && soldIn ? (path) => languages(path, (presence) => soldIn(p, presence)) : languages;
|
|
90
|
+
return [entry(base, productPath(p.handle), p.updated_at, own)];
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/** The request's host, read as the proxy reads it (`requestHostOf`). */
|
|
94
|
+
async function requestHost() {
|
|
95
|
+
return requestHostOf(await headers());
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The sitemaps the request host serves, in child-id slot order (AMB-2174): the root, then each announced subfolder;
|
|
99
|
+
* on a market's own host (`store.ca`), that market alone. Only an announced market URL (active and turned on) is
|
|
100
|
+
* listed or named in hreflang, so a store with none, or with passive (backfilled) ones only, gets today's sitemap, and
|
|
101
|
+
* so do a store on the old route tree (no `marketTreeEnv()`: it serves no market URL) and a store API without the map
|
|
102
|
+
* (404/410). A map that cannot be read throws (`getStoreUrlMap`): the sitemap
|
|
103
|
+
* answers 5xx, which crawlers retry, never a root-only sitemap. Alternates cross hosts: `store.ca` and
|
|
104
|
+
* `store.com/en-ca` name each other.
|
|
105
|
+
*/
|
|
106
|
+
async function hostSitemaps(base) {
|
|
107
|
+
const root = { slot: 0, base, market: null, alternateMarkets: [] };
|
|
108
|
+
// A store on the old route tree serves no market URL: its sitemap never reads the map and stays as before.
|
|
109
|
+
if (!isMarketTreeBuild())
|
|
110
|
+
return [root];
|
|
111
|
+
const map = await getStoreUrlMap();
|
|
112
|
+
const announced = (map?.presences.filter(isAnnounced) ?? []).map((p) => ({ presence: p, base: marketMetadataBase(keyOfPresence(p), map) ?? base }));
|
|
113
|
+
if (!map || !announced.length)
|
|
114
|
+
return [root];
|
|
115
|
+
const tag = (country) => `${map.language.split('-')[0]}-${country.toUpperCase()}`;
|
|
116
|
+
const languages = map.hreflang
|
|
117
|
+
? (path, sells) => Object.fromEntries([
|
|
118
|
+
...map.rootCountries.map((c) => [tag(c), pageUrl(base, path)]),
|
|
119
|
+
...announced.filter((m) => !sells || sells(m.presence)).flatMap((m) => m.presence.countries.map((c) => [tag(c), pageUrl(m.base, path)])),
|
|
120
|
+
['x-default', pageUrl(base, path)],
|
|
121
|
+
])
|
|
122
|
+
: undefined;
|
|
123
|
+
const alternateMarkets = languages ? announced.map((m) => m.presence) : [];
|
|
124
|
+
const own = presenceOfHost(map, await requestHost());
|
|
125
|
+
const ownMarket = own && announced.find((m) => m.presence === own);
|
|
126
|
+
if (ownMarket)
|
|
127
|
+
return [{ slot: 0, base: ownMarket.base, market: ownMarket.presence, languages, alternateMarkets }];
|
|
128
|
+
// Medusa's ordinal (never reused) keeps a market's child ids when another market URL is added or removed.
|
|
129
|
+
const slots = announced
|
|
130
|
+
.filter((m) => m.presence.kind === 'subfolder')
|
|
131
|
+
.map((m) => ({ slot: m.presence.ordinal, base: m.base, market: m.presence, languages, alternateMarkets }));
|
|
132
|
+
return [{ ...root, languages, alternateMarkets }, ...slots.sort((a, b) => a.slot - b.slot)];
|
|
133
|
+
}
|
|
134
|
+
/** The `/store/products` query of a slot's catalogue: the root's as today; a market's through its region. */
|
|
135
|
+
const catalogueQuery = (market) => (market?.regionId ? { region_id: market.regionId } : {});
|
|
136
|
+
/** How many products a slot lists: one small cached read; 0 for a market without a region. */
|
|
137
|
+
async function productCount(sitemap) {
|
|
138
|
+
if (sitemap.market && !sitemap.market.regionId)
|
|
139
|
+
return 0;
|
|
140
|
+
return (await listPage('products', { limit: 1, fields: 'id', ...catalogueQuery(sitemap.market) })).count;
|
|
59
141
|
}
|
|
60
|
-
/**
|
|
61
|
-
async function childIds() {
|
|
62
|
-
const
|
|
63
|
-
|
|
142
|
+
/** Every child id of the request host: per market slot, `0` (static pages + collections), then one per 250 of its products. */
|
|
143
|
+
async function childIds(base) {
|
|
144
|
+
const sitemaps = await hostSitemaps(base);
|
|
145
|
+
const counts = await Promise.all(sitemaps.map(productCount));
|
|
146
|
+
const ids = sitemaps.flatMap(({ slot }, i) => Array.from({ length: 1 + Math.ceil(counts[i] / PRODUCTS_PER_SITEMAP) }, (_, page) => slot * IDS_PER_MARKET + page));
|
|
147
|
+
return { ids, sitemaps };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* `GET /store/market-exclusions` (Medusa): `{ markets: [{ marketId, productIds }], regions: [{ regionId, marketIds }] }`.
|
|
151
|
+
* Each market's own exclusions once, and per region the markets (its own and every one it inherits from, resolved by
|
|
152
|
+
* Medusa) whose exclusions its `/store/products?region_id=` listing applies. A region not listed excludes nothing.
|
|
153
|
+
*/
|
|
154
|
+
const MARKET_EXCLUSIONS_ROUTE = '/store/market-exclusions';
|
|
155
|
+
/**
|
|
156
|
+
* Each region's excluded product ids, the union of its markets' (`MARKET_EXCLUSIONS_ROUTE`): ONE read per child, shared
|
|
157
|
+
* by every child of the store through Next's data cache (`sitemapRead`). Anything but a well-formed answer rejects (an
|
|
158
|
+
* older Medusa's 404, the earlier per-region shape), so the child answers 5xx (crawlers retry) and never names a market
|
|
159
|
+
* that does not sell a product.
|
|
160
|
+
*/
|
|
161
|
+
async function excludedByRegion() {
|
|
162
|
+
const { markets, regions } = (await sitemapRead(MARKET_EXCLUSIONS_ROUTE)) ?? {};
|
|
163
|
+
const marketsOk = Array.isArray(markets) && markets.every(isIdWithIds('marketId', 'productIds'));
|
|
164
|
+
const regionsOk = Array.isArray(regions) && regions.every(isIdWithIds('regionId', 'marketIds'));
|
|
165
|
+
const byMarket = new Map(marketsOk ? markets.map((market) => [market.marketId, market.productIds]) : []);
|
|
166
|
+
// A region naming a market the answer does not list is not a well-formed answer either: never "excludes nothing".
|
|
167
|
+
if (!marketsOk || !regionsOk || !regions.every((region) => region.marketIds.every((id) => byMarket.has(id)))) {
|
|
168
|
+
throw new Error(`Medusa ${MARKET_EXCLUSIONS_ROUTE} failed: not an exclusions answer`);
|
|
169
|
+
}
|
|
170
|
+
return new Map(regions.map((region) => [region.regionId, new Set(region.marketIds.flatMap((id) => byMarket.get(id) ?? []))]));
|
|
171
|
+
}
|
|
172
|
+
/** A guard for `{ [idKey]: string, [listKey]: string[] }`, the shape of each entry of the exclusions answer. */
|
|
173
|
+
function isIdWithIds(idKey, listKey) {
|
|
174
|
+
return (value) => {
|
|
175
|
+
const entry = (value ?? {});
|
|
176
|
+
const list = entry[listKey];
|
|
177
|
+
return typeof entry[idKey] === 'string' && Array.isArray(list) && list.every((id) => typeof id === 'string');
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Which announced market sells each product of a page, for its alternates: the slot's own market sells every product
|
|
182
|
+
* it lists; another market sells a product unless its region excludes it (`excludedByRegion`), and a market without a
|
|
183
|
+
* region sells none. One read per child, none when no other market has a region; never a read per product, per market
|
|
184
|
+
* or per page view: the alternates exist only in the sitemap.
|
|
185
|
+
*/
|
|
186
|
+
async function sellers(sitemap) {
|
|
187
|
+
const needed = sitemap.alternateMarkets.some((m) => m !== sitemap.market && m.regionId);
|
|
188
|
+
const excluded = needed ? await excludedByRegion() : new Map();
|
|
189
|
+
return (product, presence) => presence === sitemap.market || (!!presence.regionId && !!product.id && !excluded.get(presence.regionId)?.has(product.id));
|
|
64
190
|
}
|
|
65
191
|
/**
|
|
66
192
|
* The ids Next serves under `<dir>/sitemap/<id>.xml` (it answers 404 for any other id, so it calls this on
|
|
@@ -72,11 +198,12 @@ async function childIds() {
|
|
|
72
198
|
* calling Medusa: an outage must not fail the deploy.
|
|
73
199
|
*/
|
|
74
200
|
export async function generateSitemaps() {
|
|
75
|
-
|
|
201
|
+
const base = sitemapBase();
|
|
202
|
+
if (!base)
|
|
76
203
|
return [];
|
|
77
204
|
if (process.env.NEXT_PHASE === 'phase-production-build')
|
|
78
205
|
return [{ id: 0 }];
|
|
79
|
-
return (await childIds()).map((id) => ({ id }));
|
|
206
|
+
return (await childIds(base)).ids.map((id) => ({ id }));
|
|
80
207
|
}
|
|
81
208
|
/**
|
|
82
209
|
* One child sitemap, from ONE Medusa call. Id `0` is the static pages and collections, id `n >= 1` is
|
|
@@ -94,38 +221,56 @@ export async function sitemap(props, options) {
|
|
|
94
221
|
const id = Number(await props.id);
|
|
95
222
|
if (!base || !Number.isInteger(id) || id < 0)
|
|
96
223
|
return [];
|
|
97
|
-
|
|
224
|
+
// On the old route tree every id is the root's, as before.
|
|
225
|
+
const [slot, page] = isMarketTreeBuild() ? [Math.floor(id / IDS_PER_MARKET), id % IDS_PER_MARKET] : [0, id];
|
|
226
|
+
const marketAt = async () => (await hostSitemaps(base)).find((m) => m.slot === slot);
|
|
227
|
+
if (page === 0) {
|
|
98
228
|
const { items, count } = await listPage('collections', { limit: COLLECTIONS_PER_SITEMAP, fields: LIST_FIELDS });
|
|
99
229
|
if (count > items.length)
|
|
100
230
|
logger.warn(`sitemap: ${count - items.length} of ${count} collections are over the page cap and left out`);
|
|
101
|
-
|
|
231
|
+
const { staticPaths } = options;
|
|
232
|
+
const market = await marketAt();
|
|
233
|
+
return market ? buildPagesSitemap(market.base, items, staticPaths, market.languages) : [];
|
|
102
234
|
}
|
|
103
|
-
const
|
|
104
|
-
|
|
235
|
+
const market = await marketAt();
|
|
236
|
+
// A market without a region lists no product: its products are the root sitemap's (`productCount` gave it no page).
|
|
237
|
+
if (!market || (market.market && !market.market.regionId))
|
|
238
|
+
return [];
|
|
239
|
+
const offset = (page - 1) * PRODUCTS_PER_SITEMAP;
|
|
240
|
+
// Only a sitemap whose alternates name markets reads product ids (an old-tree store's read is today's).
|
|
241
|
+
const fields = market.alternateMarkets.length ? MARKET_LIST_FIELDS : LIST_FIELDS;
|
|
242
|
+
const { items, count, limit } = await listPage('products', { limit: PRODUCTS_PER_SITEMAP, offset, order: 'id', fields, ...catalogueQuery(market.market) });
|
|
105
243
|
// Medusa clamps `limit` silently. Children are `PRODUCTS_PER_SITEMAP` apart, so a smaller page would drop
|
|
106
244
|
// the products between pages without an error: reject, and crawlers retry instead of indexing a hole.
|
|
107
245
|
const expected = Math.min(PRODUCTS_PER_SITEMAP, Math.max(count - offset, 0));
|
|
108
246
|
if ((limit !== undefined && limit < PRODUCTS_PER_SITEMAP) || items.length < expected) {
|
|
109
247
|
throw new Error(`Medusa /store/products returned ${items.length} of ${expected} products for sitemap ${id} (page size ${limit ?? 'unknown'}, wanted ${PRODUCTS_PER_SITEMAP})`);
|
|
110
248
|
}
|
|
111
|
-
|
|
249
|
+
const soldIn = market.languages && market.alternateMarkets.length ? await sellers(market) : undefined;
|
|
250
|
+
return buildProductsSitemap(market.base, items, market.languages, soldIn);
|
|
112
251
|
}
|
|
113
252
|
/**
|
|
114
|
-
* The store's `/sitemap.xml`: a sitemap index linking every child on the primary host
|
|
115
|
-
* the children, not the index). The store's
|
|
253
|
+
* The store's `/sitemap.xml`: a sitemap index linking every child on the primary host, or on a market's own host
|
|
254
|
+
* (`store.ca`) that market's children there (Next generates the children, not the index). The store's
|
|
255
|
+
* `app/sitemap.xml/route.ts` re-exports it as `GET`. Children
|
|
116
256
|
* live at `/sitemaps/sitemap/<id>.xml`, i.e. in the store's `app/sitemaps/sitemap.ts`: Next refuses a
|
|
117
257
|
* `sitemap.ts` next to the `sitemap.xml` route at the app root. Awaits `connection()` like `sitemap`.
|
|
118
258
|
*/
|
|
119
259
|
export async function sitemapIndex() {
|
|
120
260
|
await connection();
|
|
121
261
|
const base = sitemapBase();
|
|
122
|
-
const
|
|
262
|
+
const children = base ? await childIds(base) : null;
|
|
263
|
+
// The children of a market's own host live on that host; everything else on the primary.
|
|
264
|
+
const host = children?.sitemaps[0].base;
|
|
265
|
+
const locs = children && host ? children.ids.map((id) => `<sitemap><loc>${new URL(`${SITEMAP_CHILDREN_PATH}/${id}.xml`, host).href}</loc></sitemap>`) : [];
|
|
123
266
|
const xml = `<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${locs.join('')}</sitemapindex>`;
|
|
124
267
|
return new Response(xml, { headers: { 'Content-Type': 'application/xml' } });
|
|
125
268
|
}
|
|
126
269
|
/**
|
|
127
270
|
* The store's `robots.txt`: the sitemap is advertised on the primary host, so every host the store answers
|
|
128
|
-
* on agrees
|
|
271
|
+
* on agrees, except an announced market's own host (`store.ca`), which names its own sitemap, and the private pages
|
|
272
|
+
* are disallowed under every announced subfolder too (AMB-2174, only on the `app/[m]/` tree: `marketTreeEnv()`).
|
|
273
|
+
* Awaits `connection()` so the deploy kind is read per request, not frozen into a prerendered
|
|
129
274
|
* file (a preview build promoted to production would otherwise keep serving `Disallow: /`).
|
|
130
275
|
*/
|
|
131
276
|
export async function robots() {
|
|
@@ -133,9 +278,16 @@ export async function robots() {
|
|
|
133
278
|
if (isPreviewDeploy())
|
|
134
279
|
return { rules: { userAgent: '*', disallow: '/' } };
|
|
135
280
|
const base = siteMetadataBase();
|
|
281
|
+
// robots.txt must answer during an outage: without the map it is today's file, as on the old route tree (no market URL).
|
|
282
|
+
const map = base && isMarketTreeBuild() ? await getStoreUrlMap().catch(() => null) : null;
|
|
283
|
+
const own = map ? presenceOfHost(map, await requestHost()) : null;
|
|
284
|
+
const sitemapOrigin = own && isAnnounced(own) ? marketMetadataBase(keyOfPresence(own), map) : base;
|
|
285
|
+
// On the primary host the same pages sit under every announced subfolder (`/en-ca/cart`).
|
|
286
|
+
const subfolders = own ? [] : (map?.presences.filter((p) => p.kind === 'subfolder' && p.path && isAnnounced(p)) ?? []);
|
|
287
|
+
const prefixes = subfolders.map((p) => p.path ?? '').sort();
|
|
136
288
|
return {
|
|
137
|
-
rules: { userAgent: '*', allow: '/', disallow: DISALLOWED_PATHS },
|
|
138
|
-
...(
|
|
289
|
+
rules: { userAgent: '*', allow: '/', disallow: [...DISALLOWED_PATHS, ...prefixes.flatMap((prefix) => DISALLOWED_PATHS.map((path) => prefix + path))] },
|
|
290
|
+
...(sitemapOrigin ? { sitemap: new URL('/sitemap.xml', sitemapOrigin).href } : {}),
|
|
139
291
|
};
|
|
140
292
|
}
|
|
141
293
|
//# sourceMappingURL=seo.js.map
|
package/dist/lib/seo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seo.js","sourceRoot":"","sources":["../../src/lib/seo.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GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE;QACtJ,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnF,CAAA;AACH,CAAC"}
|
package/dist/lib/site-url.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StoreUrlMap } from './market.js';
|
|
1
2
|
/**
|
|
2
3
|
* The store's canonical public origin, shared by `metadataBase`, `robots` and
|
|
3
4
|
* `sitemap` (`lib/seo`): canonical URLs and `openGraph.url` are relative and
|
|
@@ -30,4 +31,27 @@
|
|
|
30
31
|
* through `configureCore`, which exists for variables the browser needs too.
|
|
31
32
|
*/
|
|
32
33
|
export declare function siteMetadataBase(env?: Record<string, string | undefined>): URL | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The host a request names (AMB-2174): its `Host` header, lowercase, without a port (`port: true` keeps it). THE one
|
|
36
|
+
* read of it: the edge proxy (which market host a request is on, and whether it is one of the store's), the sitemaps
|
|
37
|
+
* and robots, the hosted checkout's store token (with the port: the checkout links back to the store from it) and a
|
|
38
|
+
* store's unmatched-path redirect lookup (`resolveUnmatchedPathRedirect`'s `requestHost`) all take it from here, so
|
|
39
|
+
* they always see the same host. null without one.
|
|
40
|
+
*
|
|
41
|
+
* Never `x-forwarded-host`: Next keeps a client's copy under `next start` and `next dev`, and the orchestrator's preview
|
|
42
|
+
* proxy passes one on to the sandbox. A forged one would put a preview on a market host or the primary, whose
|
|
43
|
+
* redirects a preview must never send. `Host` is right everywhere a store runs: Vercel sets it to the domain the
|
|
44
|
+
* visitor typed (and `x-forwarded-host` to the same value), a preview sandbox's is its own host (never a store's), and
|
|
45
|
+
* `next dev` / `next start` get the browser's (`storeca.localhost:3000`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function requestHostOf(headers: Pick<Headers, 'get'>, { port }?: {
|
|
48
|
+
port?: boolean;
|
|
49
|
+
}): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* `metadataBase` for a page of the store's `app/[m]/` tree (AMB-2174), on the same one rule: a subdomain or domain
|
|
52
|
+
* market is `https://<host>`, a subfolder market is the primary origin plus its path (`https://store.com/en-ca`; Next
|
|
53
|
+
* joins a relative canonical onto that path). The root key, a key the map does not hold, a market that is not active
|
|
54
|
+
* and a passive presence (backfilled, not turned on) all get the store's origin, so their canonical names the old URL.
|
|
55
|
+
*/
|
|
56
|
+
export declare function marketMetadataBase(key: string, map: StoreUrlMap | null): URL | undefined;
|
|
33
57
|
//# sourceMappingURL=site-url.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-url.d.ts","sourceRoot":"","sources":["../../src/lib/site-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,GAAG,GAAG,SAAS,CAavG"}
|
|
1
|
+
{"version":3,"file":"site-url.d.ts","sourceRoot":"","sources":["../../src/lib/site-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,GAAG,GAAG,SAAS,CAavG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,IAAY,EAAE,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,GAAG,IAAI,CAGrH;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,GAAG,GAAG,GAAG,SAAS,CAQxF"}
|
package/dist/lib/site-url.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isAnnounced, presenceOfKey } from './market.js';
|
|
1
2
|
/**
|
|
2
3
|
* The store's canonical public origin, shared by `metadataBase`, `robots` and
|
|
3
4
|
* `sitemap` (`lib/seo`): canonical URLs and `openGraph.url` are relative and
|
|
@@ -45,4 +46,38 @@ export function siteMetadataBase(env = process.env) {
|
|
|
45
46
|
}
|
|
46
47
|
return undefined;
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* The host a request names (AMB-2174): its `Host` header, lowercase, without a port (`port: true` keeps it). THE one
|
|
51
|
+
* read of it: the edge proxy (which market host a request is on, and whether it is one of the store's), the sitemaps
|
|
52
|
+
* and robots, the hosted checkout's store token (with the port: the checkout links back to the store from it) and a
|
|
53
|
+
* store's unmatched-path redirect lookup (`resolveUnmatchedPathRedirect`'s `requestHost`) all take it from here, so
|
|
54
|
+
* they always see the same host. null without one.
|
|
55
|
+
*
|
|
56
|
+
* Never `x-forwarded-host`: Next keeps a client's copy under `next start` and `next dev`, and the orchestrator's preview
|
|
57
|
+
* proxy passes one on to the sandbox. A forged one would put a preview on a market host or the primary, whose
|
|
58
|
+
* redirects a preview must never send. `Host` is right everywhere a store runs: Vercel sets it to the domain the
|
|
59
|
+
* visitor typed (and `x-forwarded-host` to the same value), a preview sandbox's is its own host (never a store's), and
|
|
60
|
+
* `next dev` / `next start` get the browser's (`storeca.localhost:3000`).
|
|
61
|
+
*/
|
|
62
|
+
export function requestHostOf(headers, { port = false } = {}) {
|
|
63
|
+
const host = headers.get('host')?.trim().toLowerCase();
|
|
64
|
+
return (port ? host : host?.replace(/:\d+$/, '')) || null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `metadataBase` for a page of the store's `app/[m]/` tree (AMB-2174), on the same one rule: a subdomain or domain
|
|
68
|
+
* market is `https://<host>`, a subfolder market is the primary origin plus its path (`https://store.com/en-ca`; Next
|
|
69
|
+
* joins a relative canonical onto that path). The root key, a key the map does not hold, a market that is not active
|
|
70
|
+
* and a passive presence (backfilled, not turned on) all get the store's origin, so their canonical names the old URL.
|
|
71
|
+
*/
|
|
72
|
+
export function marketMetadataBase(key, map) {
|
|
73
|
+
const presence = presenceOfKey(key, map);
|
|
74
|
+
if (presence && isAnnounced(presence)) {
|
|
75
|
+
if (presence.host)
|
|
76
|
+
return new URL(`https://${presence.host}`);
|
|
77
|
+
const origin = siteMetadataBase();
|
|
78
|
+
if (origin && presence.path)
|
|
79
|
+
return new URL(`${origin.origin}${presence.path}`);
|
|
80
|
+
}
|
|
81
|
+
return siteMetadataBase();
|
|
82
|
+
}
|
|
48
83
|
//# sourceMappingURL=site-url.js.map
|
package/dist/lib/site-url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-url.js","sourceRoot":"","sources":["../../src/lib/site-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA0C,OAAO,CAAC,GAAG;IACpF,sFAAsF;IACtF,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,KAAK,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,6BAA6B,CAAA;IAChG,KAAK,MAAM,SAAS,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;QAC3D,IAAI,CAAC,IAAI;YAAE,SAAQ;QACnB,IAAI,CAAC;YACH,OAAO,IAAI,GAAG,CAAC,IAAI,GAAG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AC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAA;AAC3D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,GAAuB;IACrE,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACxC,IAAI,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,IAAI,QAAQ,CAAC,IAAI;YAAE,OAAO,IAAI,GAAG,CAAC,WAAW,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7D,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAA;QACjC,IAAI,MAAM,IAAI,QAAQ,CAAC,IAAI;YAAE,OAAO,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IACjF,CAAC;IACD,OAAO,gBAAgB,EAAE,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The store routes whose GET/HEAD answer is the same for every visitor (AMB-2174): THE list, read by the server fetch
|
|
3
|
+
* shim (`lib/medusa-client.ts`, which then forwards no visitor cookie or header for them) and imported by Medusa's
|
|
4
|
+
* mirror spec (medusa-backend-orchestrator `src/api/store/visitor-independent-routes.spec.ts`), which proves each one
|
|
5
|
+
* never reads the visitor. An ALLOWLIST of exactly the shapes core calls: a `:name` segment is one path segment, named
|
|
6
|
+
* as Medusa's route folder (`[blog]`). Any route not here keeps the visitor.
|
|
7
|
+
*
|
|
8
|
+
* Proven by Medusa for each: the `/store/*` middlewares read visitor headers only for products, search, regions and
|
|
9
|
+
* product extensions (carts have their own); each route here computes its answer from the store alone
|
|
10
|
+
* (`checkout-settings` reads a `?cart_id=` cart's own country, never the visitor's; `market-exclusions` is every
|
|
11
|
+
* region's exclusions, the sitemaps' alternates). Not here, so per visitor:
|
|
12
|
+
* products, search, regions, product extensions, carts, customers, orders, and `/store/collections`, which leaves out
|
|
13
|
+
* products excluded in the shopper's market.
|
|
14
|
+
*
|
|
15
|
+
* Plain data, no imports: a CommonJS consumer can load it as it is.
|
|
16
|
+
*/
|
|
17
|
+
export declare const VISITOR_FREE_ROUTES: readonly string[];
|
|
18
|
+
//# sourceMappingURL=visitor-free-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-free-routes.d.ts","sourceRoot":"","sources":["../../src/lib/visitor-free-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAehD,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The store routes whose GET/HEAD answer is the same for every visitor (AMB-2174): THE list, read by the server fetch
|
|
3
|
+
* shim (`lib/medusa-client.ts`, which then forwards no visitor cookie or header for them) and imported by Medusa's
|
|
4
|
+
* mirror spec (medusa-backend-orchestrator `src/api/store/visitor-independent-routes.spec.ts`), which proves each one
|
|
5
|
+
* never reads the visitor. An ALLOWLIST of exactly the shapes core calls: a `:name` segment is one path segment, named
|
|
6
|
+
* as Medusa's route folder (`[blog]`). Any route not here keeps the visitor.
|
|
7
|
+
*
|
|
8
|
+
* Proven by Medusa for each: the `/store/*` middlewares read visitor headers only for products, search, regions and
|
|
9
|
+
* product extensions (carts have their own); each route here computes its answer from the store alone
|
|
10
|
+
* (`checkout-settings` reads a `?cart_id=` cart's own country, never the visitor's; `market-exclusions` is every
|
|
11
|
+
* region's exclusions, the sitemaps' alternates). Not here, so per visitor:
|
|
12
|
+
* products, search, regions, product extensions, carts, customers, orders, and `/store/collections`, which leaves out
|
|
13
|
+
* products excluded in the shopper's market.
|
|
14
|
+
*
|
|
15
|
+
* Plain data, no imports: a CommonJS consumer can load it as it is.
|
|
16
|
+
*/
|
|
17
|
+
export const VISITOR_FREE_ROUTES = [
|
|
18
|
+
'/store/url-map',
|
|
19
|
+
'/store/url-redirects',
|
|
20
|
+
'/store/content/blogs',
|
|
21
|
+
'/store/content/blogs/:blog/articles',
|
|
22
|
+
'/store/content/blogs/:blog/articles/:handle',
|
|
23
|
+
'/store/content/blogs/:blog/articles/:handle/comments',
|
|
24
|
+
'/store/metaobjects/:type',
|
|
25
|
+
'/store/metaobjects/:type/:handle',
|
|
26
|
+
'/store/config',
|
|
27
|
+
'/store/brand',
|
|
28
|
+
'/store/integrations/active',
|
|
29
|
+
'/store/policies',
|
|
30
|
+
'/store/checkout-settings',
|
|
31
|
+
'/store/market-exclusions',
|
|
32
|
+
];
|
|
33
|
+
//# sourceMappingURL=visitor-free-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-free-routes.js","sourceRoot":"","sources":["../../src/lib/visitor-free-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,qCAAqC;IACrC,6CAA6C;IAC7C,sDAAsD;IACtD,0BAA0B;IAC1B,kCAAkC;IAClC,eAAe;IACf,cAAc;IACd,4BAA4B;IAC5B,iBAAiB;IACjB,0BAA0B;IAC1B,0BAA0B;CAC3B,CAAA"}
|
|
@@ -53,6 +53,37 @@ export type WithAmborasCore<T> = T & {
|
|
|
53
53
|
};
|
|
54
54
|
turbopack?: Record<string, unknown>;
|
|
55
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* The build-time opt-in of a store on the `app/[m]/` tree (AMB-2174), spread into its next.config `env`:
|
|
58
|
+
*
|
|
59
|
+
* env: { ...marketTreeEnv(), NEXT_PUBLIC_MEDUSA_BACKEND_URL: … },
|
|
60
|
+
*
|
|
61
|
+
* With it, the server fetch shim reads no cookie for the visitor-independent store routes (the URL map, redirects,
|
|
62
|
+
* blog and metaobject reads, the store's config, brand, integrations, policies and checkout settings), so a page
|
|
63
|
+
* whose reads are all of those renders statically. Without it (every store on the old tree) the shim reads the
|
|
64
|
+
* visitor on every backend fetch, exactly as before. `amboras-check market-routes` requires it on an `app/[m]/` tree.
|
|
65
|
+
*/
|
|
66
|
+
export declare function marketTreeEnv(): Record<string, string>;
|
|
67
|
+
/** A Next rewrite (`source` and `destination` path patterns). */
|
|
68
|
+
export interface RewriteRule {
|
|
69
|
+
source: string;
|
|
70
|
+
destination: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The `afterFiles` rewrites of a store on the `app/[m]/` tree (AMB-2174): a path with a file extension that no file or
|
|
74
|
+
* route answered (`/old.pdf`, `/files/x.pdf`, `/en-ca/old.html`) goes to the root key, `/_/<path>`, query kept, where
|
|
75
|
+
* the catch-all `app/[m]/[...slug]` looks up the merchant's URL redirect (else 404), as on the old tree. The lookup
|
|
76
|
+
* takes the market from the key `marketProxy` names (`MARKET_KEY_HEADER`), so `/en-ca/catalog.pdf` finds the root's
|
|
77
|
+
* `/catalog.pdf` redirect, prefixed. `marketProxy` never rewrites such paths, and Next applies `afterFiles` after the
|
|
78
|
+
* public files and the static routes and before the dynamic ones, so a real file is never touched and `app/[m]` never
|
|
79
|
+
* sees the path first. Never matched: a first segment starting with `_` (`/_next/…`, an internal key, so it cannot
|
|
80
|
+
* loop) and the top-level folders (`/api`, `/sitemaps`, `/.well-known`), whose dynamic routes stay theirs.
|
|
81
|
+
*
|
|
82
|
+
* async rewrites() { return { beforeFiles: [], afterFiles: marketFallbackRewrites(), fallback: [] } }
|
|
83
|
+
*
|
|
84
|
+
* Only on the `app/[m]/` tree: an old tree has no `app/[m]` and answers these paths with its own catch-all.
|
|
85
|
+
*/
|
|
86
|
+
export declare function marketFallbackRewrites(): RewriteRule[];
|
|
56
87
|
export declare function withAmborasCore<T extends NextConfigLike>(config?: T, options?: AmborasCoreOptions): WithAmborasCore<T>;
|
|
57
88
|
export {};
|
|
58
89
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next-config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next-config/index.ts"],"names":[],"mappings":"AAkCA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAA;IAC5B,2GAA2G;IAC3G,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAGD,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC9C,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,cAAc,CAAC,EAAE,aAAa,EAAE,CAAA;KAAE,CAAA;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,YAAY,iCAAiC,CAAA;AAkB1D,gGAAgG;AAChG,eAAO,MAAM,4BAA4B,EAAE,aAAa,EAcvD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,EAAiC,CAAA;AASjF,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AA8C7C,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,GAAG,GAAE,GAAkB,GAAG,MAAM,CAS9D;AA+ED;;;;;GAKG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAuBzE;AAMD,mFAAmF;AACnF,wBAAgB,eAAe,IAAI,aAAa,EAAE,CASjD;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI,CAQpE;AAID,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG;IACnC,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,cAAc,EAAE,aAAa,EAAE,CAAA;KAAE,CAAA;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEtD;AAED,iEAAiE;AACjE,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,IAAI,WAAW,EAAE,CAEtD;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EACtD,MAAM,GAAE,CAAW,EACnB,OAAO,GAAE,kBAAuB,GAC/B,eAAe,CAAC,CAAC,CAAC,CA2BpB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// withAmborasCore(): the platform part of a store's next.config.mjs.
|
|
1
|
+
// withAmborasCore(): the platform part of a store's next.config.mjs (and marketFallbackRewrites() for the app/[m]/ tree).
|
|
2
2
|
//
|
|
3
3
|
// import { resolveAmborasImageHosts, withAmborasCore } from '@amboras-dev/storefront-core/next-config'
|
|
4
4
|
//
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
// billed to us; any hostname holding `*` throws.
|
|
30
30
|
// 3. turbopack.root: pinned to the store package, so Next 16 does not infer
|
|
31
31
|
// the workspace root from an unrelated lockfile higher up.
|
|
32
|
+
import { FILE_PATH, MARKET_TREE_ENV } from '../lib/market.js';
|
|
32
33
|
export const CORE_PACKAGE = '@amboras-dev/storefront-core';
|
|
33
34
|
// ── amboras:image-hosts-reader (v1) ──────────────────────────────────────────
|
|
34
35
|
//
|
|
@@ -268,6 +269,36 @@ export function assertNoWildcardHost(patterns) {
|
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
const patternKey = (p) => [p.protocol ?? '', p.hostname, p.port ?? '', p.pathname ?? '', p.search ?? ''].join('|');
|
|
272
|
+
/**
|
|
273
|
+
* The build-time opt-in of a store on the `app/[m]/` tree (AMB-2174), spread into its next.config `env`:
|
|
274
|
+
*
|
|
275
|
+
* env: { ...marketTreeEnv(), NEXT_PUBLIC_MEDUSA_BACKEND_URL: … },
|
|
276
|
+
*
|
|
277
|
+
* With it, the server fetch shim reads no cookie for the visitor-independent store routes (the URL map, redirects,
|
|
278
|
+
* blog and metaobject reads, the store's config, brand, integrations, policies and checkout settings), so a page
|
|
279
|
+
* whose reads are all of those renders statically. Without it (every store on the old tree) the shim reads the
|
|
280
|
+
* visitor on every backend fetch, exactly as before. `amboras-check market-routes` requires it on an `app/[m]/` tree.
|
|
281
|
+
*/
|
|
282
|
+
export function marketTreeEnv() {
|
|
283
|
+
return { [MARKET_TREE_ENV]: '1' };
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The `afterFiles` rewrites of a store on the `app/[m]/` tree (AMB-2174): a path with a file extension that no file or
|
|
287
|
+
* route answered (`/old.pdf`, `/files/x.pdf`, `/en-ca/old.html`) goes to the root key, `/_/<path>`, query kept, where
|
|
288
|
+
* the catch-all `app/[m]/[...slug]` looks up the merchant's URL redirect (else 404), as on the old tree. The lookup
|
|
289
|
+
* takes the market from the key `marketProxy` names (`MARKET_KEY_HEADER`), so `/en-ca/catalog.pdf` finds the root's
|
|
290
|
+
* `/catalog.pdf` redirect, prefixed. `marketProxy` never rewrites such paths, and Next applies `afterFiles` after the
|
|
291
|
+
* public files and the static routes and before the dynamic ones, so a real file is never touched and `app/[m]` never
|
|
292
|
+
* sees the path first. Never matched: a first segment starting with `_` (`/_next/…`, an internal key, so it cannot
|
|
293
|
+
* loop) and the top-level folders (`/api`, `/sitemaps`, `/.well-known`), whose dynamic routes stay theirs.
|
|
294
|
+
*
|
|
295
|
+
* async rewrites() { return { beforeFiles: [], afterFiles: marketFallbackRewrites(), fallback: [] } }
|
|
296
|
+
*
|
|
297
|
+
* Only on the `app/[m]/` tree: an old tree has no `app/[m]` and answers these paths with its own catch-all.
|
|
298
|
+
*/
|
|
299
|
+
export function marketFallbackRewrites() {
|
|
300
|
+
return [{ source: `/:path(${FILE_PATH})`, destination: '/_/:path' }];
|
|
301
|
+
}
|
|
271
302
|
export function withAmborasCore(config = {}, options = {}) {
|
|
272
303
|
const env = processEnv();
|
|
273
304
|
const medusaUrl = options.medusaUrl ?? env.NEXT_PUBLIC_MEDUSA_BACKEND_URL;
|