From f6c8e1fdf6b9d86d969290b1acb7280bcec27cf3 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 21 Jul 2020 13:15:00 +0200 Subject: [PATCH] Custom route for product details when localhost. --- frontend/components/Product.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/components/Product.vue b/frontend/components/Product.vue index 02c3193..7a54ff1 100644 --- a/frontend/components/Product.vue +++ b/frontend/components/Product.vue @@ -66,7 +66,11 @@ export default { const productSlug = this.$route.params.slug - fetch(`http://localhost:30010/api/product/${ productSlug }`) + let url = `/api/products/${ productSlug }`; + if (window.location.href.includes('localhost')) + url = 'http://localhost:30010'.concat(url) + + fetch(url) .then(resp => resp.json()) .then(product => this.product = product); },