Dynamic pages proxy with pretty url fails on builds

Hey guys, I need your help with something. I’ve got a proxy that shows some weird, unexpected behavior:

data.products.each do |product|
  proxy "products/#{product[1][:title].parameterize}/", "product.html", locals: {product: product[1]}, layout: 'layout', ignore: true
end

The proxy works in development, but fails on build:

error  build/products/coffea-liberica/
No such file or directory @ rb_file_s_rename - (/var/folders/gb/7k5y3_k963gbkjwg6fq918sw0000gn/T/coffea-liberica20180818-2096-1yh4umu, build/products/coffea-liberica/)

Without pretty urls, the proxy works:

data.products.each do |product|
  proxy "/products/#{product[1][:title].parameterize}.html", "product.html", locals: {product: product[1]}, layout: 'layout', ignore: true
end

The yaml looks like this:

title: Coffea Arabica
date: 2018-08-17T22:42:07.084Z
image: /images/uploads/product-01.png

body: >-
  Coffea arabica, also known as the Arabian coffee, "coffee shrub of Arabia",
  "mountain coffee", or "arabica coffee", is a species of Coffea. It is believed
  to be the first species of coffee to be cultivated, and is the dominant
  cultivar, representing some 60% of global production. Coffee produced from the
  less acidic, more bitter, and more highly caffeinated robusta bean makes up
  the preponderance of the balance.

Any ideas?

If anyone runs into the same problem: The solution was to use an absolute URL /product/#{product[1][:title].parameterize}/index.html

Working proxy:

data.products.each do |product|
  proxy "/product/#{product[1][:title].parameterize}/index.html", "product.html", 
  locals: {product: product[1]}, 
  layout: 'product-detail',
  ignore: true
end
2 Likes