Skip to content

Commit f8186e1

Browse files
authored
Merge pull request #28 from adobe-rnd/fix-r2-bindings
fix: r2 bindings
2 parents 375def5 + 316858d commit f8186e1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/content/helix-commerce.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export async function handle(ctx, config) {
2727
return errorResponse(404, 'missing sku or urlkey');
2828
}
2929

30-
config.env = 'prod';
3130
const product = await fetchProduct(ctx, config, sku);
3231
const html = HTML_TEMPLATE(product, product.variants);
3332
return new Response(html, {

src/utils/r2.js

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import { errorWithResponse } from './http.js';
2222
* @returns {Promise<Product>} - A promise that resolves to the product.
2323
*/
2424
export async function fetchProduct(ctx, config, sku) {
25+
const { log } = ctx;
2526
const key = `${config.org}/${config.site}/${config.env}/${config.storeCode}/${config.storeViewCode}/products/${sku}.json`;
27+
log.debug('Fetching product from R2:', key);
2628
const object = await ctx.env.CATALOG_BUCKET.get(key);
2729

2830
if (!object) {

wrangler.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kv_namespaces = [
1414
[[r2_buckets]]
1515
binding = "CATALOG_BUCKET"
1616
preview_bucket_name = "adobe-commerce-catalog-dev"
17-
bucket_name = "adobe-commerce-catalog-ci"
17+
bucket_name = "adobe-commerce-catalog-dev"
1818

1919
[vars]
2020
VERSION = "@@VERSION@@-dev"
@@ -33,7 +33,7 @@ kv_namespaces = [
3333
[[env.ci.r2_buckets]]
3434
binding = "CATALOG_BUCKET"
3535
preview_bucket_name = "adobe-commerce-catalog-dev"
36-
bucket_name = "adobe-commerce-catalog-ci"
36+
bucket_name = "adobe-commerce-catalog-dev"
3737

3838
[env.ci.vars]
3939
VERSION = "@@VERSION@@-ci"
@@ -49,6 +49,11 @@ kv_namespaces = [
4949
{ binding = "CONFIGS", id = "bb91e12a65a8462282396f32e63406f1", preview_id = "bb91e12a65a8462282396f32e63406f1" }
5050
]
5151

52+
[[env.production.r2_buckets]]
53+
binding = "CATALOG_BUCKET"
54+
preview_bucket_name = "adobe-commerce-catalog-dev"
55+
bucket_name = "adobe-commerce-catalog"
56+
5257
[env.production.vars]
5358
VERSION = "@@VERSION@@"
5459
ENVIRONMENT = "prod"

0 commit comments

Comments
 (0)