From cd5a93fb8f477338d7a5b25eaa2a12335d62c142 Mon Sep 17 00:00:00 2001 From: charlene tau express Date: Thu, 6 Mar 2025 15:02:14 +0800 Subject: [PATCH] add localstorage to search type --- docker/nginx.conf | 13 +++++++++++++ src/components/InputFieldCard.vue | 17 ++++++++++++----- src/components/TableComp.vue | 16 ++++++++++------ src/utils/api.ts | 7 ++++++- src/views/HomeView.vue | 2 +- vite.config.ts | 7 +++++++ 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/docker/nginx.conf b/docker/nginx.conf index 985f2e0..9adf34b 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -27,4 +27,17 @@ server { return 204; } } + + location /recommend { + proxy_pass https://192.168.99.121; # Forward request to backend + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # Ensure query parameters are preserved + proxy_pass_request_body on; + proxy_pass_request_headers on; + proxy_set_header Connection ""; + } } diff --git a/src/components/InputFieldCard.vue b/src/components/InputFieldCard.vue index 6aa1f86..b27ef84 100644 --- a/src/components/InputFieldCard.vue +++ b/src/components/InputFieldCard.vue @@ -14,7 +14,7 @@
- @@ -49,7 +49,7 @@
\ No newline at end of file diff --git a/src/components/TableComp.vue b/src/components/TableComp.vue index 6aedc45..ca52308 100644 --- a/src/components/TableComp.vue +++ b/src/components/TableComp.vue @@ -10,7 +10,7 @@ -
+
@@ -40,11 +40,14 @@ import { useSearchStore } from "@/stores/searchStore"; import {fetchData} from "@/utils/api.ts" import { useRouter } from "vue-router"; const searchStore = useSearchStore(); - -const responseData = ref("") +// interface ApiResponse { +// data: any[]; // Adjust this type according to your API response +// } +const responseData = ref({ data: [] }) const searchWhat = ref(searchStore.searchParams.query) const query={...searchStore.searchParams} +const noData=ref(false) const keys_of_a_data=ref() @@ -64,14 +67,15 @@ onMounted(()=>{ } fetchData("/search",requestType,query).then(response =>{ - if (response.data.length===0){ + noData.value=true - - responseData.value="" + // responseData.value={} + console.log("temporary") } else { + noData.value=false responseData.value = response if(requestType==="POST"){ diff --git a/src/utils/api.ts b/src/utils/api.ts index 03abb95..4e0a167 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -18,7 +18,12 @@ export const fetchData = async(endpoints="", requestType="GET", requestBody:Reco let response; if (requestBody?.search_type==="semantic"){ - response = await fetch("/recommend", options) + const params = new URLSearchParams({ + clause: requestBody?.query + }).toString(); + + + response = await fetch(`/recommend?${params}`, options) } else { diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 2f6ad47..8d2a727 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -3,7 +3,7 @@ import InputFieldCard from '@/components/InputFieldCard.vue' diff --git a/vite.config.ts b/vite.config.ts index 3e8e41b..494c3ee 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,6 +17,13 @@ export default defineConfig({ target: "https://192.168.99.121", changeOrigin: true, secure: false, // Ignores SSL certificate issues + // configure: (proxy) => { + // proxy.on('proxyReq', (proxyReq, req) => { + // console.log('Incoming request URL:', req.url); // Logs request URL + // console.log('Final URL sent to backend:', proxyReq.path); // Logs what Vite sends + // console.log('Final URL sent to backend:', proxyReq) + // }); + // } }, }, },