diff --git a/backend/src/main.ts b/backend/src/main.ts index 9ec3a1e..78934ad 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -18,6 +18,7 @@ async function bootstrap() { "https://www.placebo.mk", "https://placebo.mk", "http://localhost:5173", + 'https://imkapi.oblak.solutions', ], methods: "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS", credentials: true, @@ -27,6 +28,7 @@ async function bootstrap() { "Content-Type", "Accept", "Authorization", + 'Access-Control-Allow-Headers', "Access-Control-Allow-Origin", "Access-Control-Allow-Credentials", ], diff --git a/docker-compose.yml b/docker-compose.yml index 6a08295..a3f78a4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,6 +30,8 @@ services: - SMTP_USER=${SMTP_USER} - SMTP_PASS=${SMTP_PASS} - EMAIL_FROM=${EMAIL_FROM} + - CORS_ORIGINS=http://localhost:5173,https://www.placebo.mk,https://placebo.mk + - CORS_CREDENTIALS=true depends_on: postgres: condition: service_healthy diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 327228e..e7aae1a 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -1,32 +1,32 @@ +// vite.config.js import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; -// https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], - // server: { - // port: 5173, - // proxy: { - // "/api": { - // target: "http://localhost:3000", - // changeOrigin: true, - // secure: false, - // }, - // }, - // }, - build: { - outDir: "dist", - sourcemap: false, - rollupOptions: { - output: { - manualChunks: { - vendor: ["react", "react-dom", "react-router-dom"], - ui: ["@headlessui/react", "@heroicons/react"], + server: { + proxy: { + "/api": { + target: "https://imkapi.oblak.solutions", + changeOrigin: true, + secure: false, + ws: true, + configure: (proxy, _options) => { + proxy.on("error", (err, _req, _res) => { + console.log("proxy error", err); + }); + proxy.on("proxyReq", (proxyReq, req, _res) => { + console.log("Sending Request to the Target:", req.method, req.url); + }); + proxy.on("proxyRes", (proxyRes, req, _res) => { + console.log( + "Received Response from the Target:", + proxyRes.statusCode, + req.url, + ); + }); }, }, }, }, - define: { - "process.env.API_URL": JSON.stringify("https://imkapi.oblak.solutions"), - }, });