diff --git a/ui/nginx.conf b/ui/nginx.conf index 6cd380c..1487da8 100644 --- a/ui/nginx.conf +++ b/ui/nginx.conf @@ -7,4 +7,8 @@ server { location / { try_files $uri $uri/ /index.html; } + + location /payments { + proxy_pass http://bankservice-api:8080; + } } diff --git a/ui/src/stores/payment.js b/ui/src/stores/payment.js index 08b7296..6293d00 100644 --- a/ui/src/stores/payment.js +++ b/ui/src/stores/payment.js @@ -1,27 +1,27 @@ -import { defineStore } from 'pinia' +import { defineStore } from "pinia"; -export const usePaymentStore = defineStore('payment', { +export const usePaymentStore = defineStore("payment", { state: () => ({ data: {}, inloading: false }), actions: { async get(id) { - await fetch(`${import.meta.env.VITE_BACKEND_URL}/payments/${id}/`).then(async (response) => { - this.data = await response.json() - }) - return this.data + await fetch(`/payments/${id}/`).then(async (response) => { + this.data = await response.json(); + }); + return this.data; }, async pay(id) { - this.inloading = true - let result = 400 + this.inloading = true; + let result = 400; - await fetch(`${import.meta.env.VITE_BACKEND_URL}/payments/${id}/pay/`, { method: 'POST' }) + await fetch(`/payments/${id}/pay/`, { method: "POST" }) .then(async (response) => { - result = response.status + result = response.status; }) .finally(() => { - this.inloading = false - }) + this.inloading = false; + }); - return result - } - } -}) + return result; + }, + }, +}); diff --git a/ui/vite.config.js b/ui/vite.config.js index 5c45e1d..df8eea7 100644 --- a/ui/vite.config.js +++ b/ui/vite.config.js @@ -1,16 +1,17 @@ -import { fileURLToPath, URL } from 'node:url' +import { fileURLToPath, URL } from "node:url"; -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' +import { defineConfig } from "vite"; +import vue from "@vitejs/plugin-vue"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [ - vue(), - ], + proxy: { + "/payments": "http://bankservice-api:8080", + }, + plugins: [vue()], resolve: { alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)) - } - } -}) + "@": fileURLToPath(new URL("./src", import.meta.url)), + }, + }, +});