In my Nuxt project set to "spa" mode, I am facing an issue with a URL containing a dynamic parameter /shop/:product
, which could have various values such as:
/shop/ipad-128gb-rose-gold
/shop/subway-gift-card
/shop/any-string
and so on.
This setup works perfectly in the development environment with the following directory structure:
pages/
shop/
_product.vue
However, when it comes to production, I noticed that the bin/
folder generated by Nuxt does not contain anything inside the shop/
directory. Nuxt provides a solution for this situation here: https://nuxtjs.org/api/configuration-generate/#routes
My dilemma lies in the fact that I do not know what value the :product
param will hold (it can be any string).
I retrieve the details of the product in pages/shop/_product.vue
from the server, handling errors if necessary. How can I achieve this functionality in a production build?
I find myself confused about the approach suggested by Nuxt -- am I expected to generate routes for every possible product slug?