[object Object]

← back to Carmelwallpapers

render: route buy CTA + View Full Product + card sample link through /buy/:slug (kill vendor-handle DOM leak; mirrors fleet a85eb02)

afaefa4a3b23a6bb998b1e1ebbd47bd35481faaa · 2026-05-31 21:01:47 -0700 · Steve Abrams

Files touched

Diff

commit afaefa4a3b23a6bb998b1e1ebbd47bd35481faaa
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sun May 31 21:01:47 2026 -0700

    render: route buy CTA + View Full Product + card sample link through /buy/:slug (kill vendor-handle DOM leak; mirrors fleet a85eb02)
---
 server.js | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/server.js b/server.js
index f28a475..d13add5 100644
--- a/server.js
+++ b/server.js
@@ -396,6 +396,18 @@ app.get('/health', (req, res) => {
 });
 
 // ── Product detail ────────────────────────────────────────────────────────────
+// /buy/:slug — internal 302 to the main store. Resolves a vendor-redacted slug
+// to the real handle SERVER-SIDE so the raw vendor-bearing handle never appears
+// in customer-facing HTML (mirrors dw-domain-fleet a85eb02). ?sample → #sample.
+app.get('/buy/:slug', (req, res) => {
+  const key = req.params.slug;
+  const p = PRODUCTS.find(x => x.handle === key)
+         || PRODUCTS.find(x => redactVendorSlug(x.handle) === key);
+  if (!p) return res.status(404).send('<h1>Not found</h1>');
+  const dest = p.product_url || `https://designerwallcoverings.com/products/${p.handle}`;
+  res.redirect(302, dest + (req.query.sample != null ? '#sample' : ''));
+});
+
 app.get('/p/:handle', (req, res) => {
   // Dual-key: new redacted-slug URLs AND legacy real-handle URLs both resolve.
   const key = req.params.handle;
@@ -425,8 +437,8 @@ ${HEADER_HTML()}
       <h1 class="detail-title">${p.title}</h1>
       <div class="detail-tags">${tags.slice(0,10).map(t=>`<span class="tag">${t}</span>`).join('')}</div>
       <div class="detail-ctas">
-        <a href="${p.sample_url}" class="btn btn-sample" target="_blank" rel="noopener noreferrer">Order Memo Sample (free)</a>
-        <a href="${p.product_url}" class="btn btn-full" target="_blank" rel="noopener noreferrer">View Full Product</a>
+        <a href="/buy/${p.slug}?sample" class="btn btn-sample" target="_blank" rel="noopener noreferrer">Order Memo Sample (free)</a>
+        <a href="/buy/${p.slug}" class="btn btn-full" target="_blank" rel="noopener noreferrer">View Full Product</a>
       </div>
       <div class="detail-service">
         <h3>Carmel Trade Service</h3>
@@ -637,7 +649,7 @@ function renderCard(p) {
         <p class="card-aesthetic">\${p.aesthetic}</p>
       </div>
     </a>
-    <a href="\${p.sample_url}" class="card-sample" target="_blank" rel="noopener noreferrer" aria-label="Order free memo sample of \${p.title.replace(/"/g,'&quot;')}">Order Memo Sample (free)</a>
+    <a href="/buy/\${p.slug||p.handle}?sample" class="card-sample" target="_blank" rel="noopener noreferrer" aria-label="Order free memo sample of \${p.title.replace(/"/g,'&quot;')}">Order Memo Sample (free)</a>
   \`;
   return div;
 }

← b8d3c3a Add per-site favicon (kills /favicon.ico 404)  ·  back to Carmelwallpapers  ·  Unique clean image hero (fleet hero dedup 2026-06-01) e802dce →