This commit is contained in:
simon.franken
2026-02-16 17:12:47 +01:00
parent a9228d19c8
commit fc06dac40e
11 changed files with 49 additions and 46 deletions

View File

@@ -1,6 +1,9 @@
# Build stage
FROM node:20-alpine as builder
ARG VITE_API_URL
ENV VITE_API_URL=${VITE_API_URL}
WORKDIR /app
COPY package*.json ./

View File

@@ -1,7 +1,7 @@
import axios from "axios";
import type { User } from "@/types";
const AUTH_BASE = "/api/auth";
const AUTH_BASE = import.meta.env.VITE_API_URL + "/auth";
export const authApi = {
login: (): void => {

View File

@@ -1,7 +1,7 @@
import axios, { AxiosError } from "axios";
const apiClient = axios.create({
baseURL: "/api",
baseURL: import.meta.env.VITE_API_URL,
headers: {
"Content-Type": "application/json",
},

13
frontend/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
interface ViteTypeOptions {
// By adding this line, you can make the type of ImportMetaEnv strict
// to disallow unknown keys.
// strictImportMetaEnv: unknown
}
interface ImportMetaEnv {
VITE_API_URL: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

View File

@@ -2,22 +2,16 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
const backend = "http://127.0.0.1:3001";
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
port: 5173,
proxy: {
"/api": {
target: backend,
changeOrigin: true,
export default defineConfig(() => {
return {
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
},
server: {
port: 5173,
},
};
});