Added backend URL to .env configuration.

main
Eloi Zalczer 2024-06-17 15:17:08 +02:00
parent 1540527b9c
commit fa49ed91a8
3 changed files with 24 additions and 11 deletions

View File

@ -2,6 +2,10 @@
FROM node:16-alpine as build FROM node:16-alpine as build
WORKDIR /app WORKDIR /app
# Assign environments variables
ARG VITE_POCKETBASE_BASE_ROUTE
ENV VITE_POCKETBASE_BASE_ROUTE=${VITE_POCKETBASE_BASE_ROUTE}
COPY package.json ./ COPY package.json ./
RUN ["npm", "install"] RUN ["npm", "install"]
COPY . . COPY . .

View File

@ -6,6 +6,9 @@ services:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
args:
VITE_POCKETBASE_BASE_ROUTE: "$VITE_POCKETBASE_BASE_ROUTE"
ports: ports:
- "${DOXFOOD_SERVER_PORT:-9000}:80" - "${DOXFOOD_SERVER_PORT:-9000}:80"

View File

@ -1,9 +1,11 @@
import { fileURLToPath, URL } from "node:url"; import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite"; import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [vue()], plugins: [vue()],
resolve: { resolve: {
alias: { alias: {
@ -14,4 +16,8 @@ export default defineConfig({
host: "127.0.0.1", host: "127.0.0.1",
cors: true, cors: true,
}, },
define: {
"import.meta.env.VITE_POCKETBASE_BASE_ROUTE": JSON.stringify(env.VITE_POCKETBASE_BASE_ROUTE),
},
};
}); });