REST Service for POPCORN - ILIAS
alex
2025-06-03 e204f6b81a1dff8e2335f4794992acece1a08b3d
fixing paths for prod
1 files added
6 files modified
87 ■■■■■ changed files
package-lock.json 13 ●●●●● patch | view | raw | blame | history
package.json 1 ●●●● patch | view | raw | blame | history
vite.config.js 53 ●●●●● patch | view | raw | blame | history
vue/.env.example 3 ●●●●● patch | view | raw | blame | history
vue/src/App.vue 2 ●●● patch | view | raw | blame | history
vue/src/pages/KursDetail.vue 3 ●●●●● patch | view | raw | blame | history
vue/src/router.js 12 ●●●● patch | view | raw | blame | history
package-lock.json
@@ -10,6 +10,7 @@
      "dependencies": {
        "@fastify/static": "^8.2.0",
        "@vueuse/core": "^13.3.0",
        "dotenv": "^16.5.0",
        "fastify": "^5.3.3",
        "lodash": "^4.17.21",
        "mysql2": "^3.14.1",
@@ -2375,6 +2376,18 @@
        "node": ">=6"
      }
    },
    "node_modules/dotenv": {
      "version": "16.5.0",
      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
      "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=12"
      },
      "funding": {
        "url": "https://dotenvx.com"
      }
    },
    "node_modules/eastasianwidth": {
      "version": "0.2.0",
      "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
package.json
@@ -14,6 +14,7 @@
  "dependencies": {
    "@fastify/static": "^8.2.0",
    "@vueuse/core": "^13.3.0",
    "dotenv": "^16.5.0",
    "fastify": "^5.3.3",
    "lodash": "^4.17.21",
    "mysql2": "^3.14.1",
vite.config.js
@@ -1,29 +1,40 @@
import { fileURLToPath, URL } from 'node:url'
import {fileURLToPath, URL} from 'node:url'
import * as path from 'node:path'
import { defineConfig } from 'vite'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import dotenv from 'dotenv'
let envPath = path.resolve(process.cwd(), "vue", '.env')
if (process.env.VITE_ENV == 'production') {
   envPath += ".production"
}
console.log("> envPath", envPath)
dotenv.config({path: envPath})
const routerBase = `${process.env.VITE_ROUTER_BASE}/ui`
console.log("+ ROUTER BASE IS", routerBase)
// https://vite.dev/config/
export default defineConfig({
  base: "/ui",
  root: path.join(__dirname, 'vue'),
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./vue/src', import.meta.url))
    },
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:4101',
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/api/, ''),
   base: routerBase,
   root: path.join(__dirname, 'vue'),
   plugins: [
      vue(),
      vueDevTools(),
   ],
   resolve: {
      alias: {
         '@': fileURLToPath(new URL('./vue/src', import.meta.url))
      },
    },
  },
   },
   server: {
      proxy: {
         '/api': {
            target: 'http://localhost:4101',
            changeOrigin: true,
            // rewrite: (path) => path.replace(/^\/api/, ''),
         },
      },
   },
})
vue/.env.example
New file
@@ -0,0 +1,3 @@
VITE_API_BASE="/api"
VITE_ILIAS_BASE="http://localhost:8060"
VITE_ROUTER_BASE=""
vue/src/App.vue
@@ -8,7 +8,7 @@
console.log("import.meta.env.VITE_API_BASE",import.meta.env.VITE_API_BASE)
console.log("import.meta.env.VITE_ILIAS_BASE",import.meta.env.VITE_ILIAS_BASE)
console.log("import.meta.env.VITE_ROUTER_BASE",import.meta.env.VITE_ILIAS_BASE)
console.log("import.meta.env.VITE_ROUTER_BASE",import.meta.env.VITE_ROUTER_BASE)
const apiToken = ref("")
vue/src/pages/KursDetail.vue
@@ -29,7 +29,6 @@
   console.log(dataKursTn)
   kursTn.value = dataKursTn
   console.log(222222222222,import.meta.env.VITE_TST)
}
const aaa = import.meta.env.VITE_TST
@@ -39,11 +38,9 @@
<template>
   <div>
      <pre>---{{aaa}}</pre>
      <h1>
         Kurs
         <small>{{ kurs?.title }}</small>
         <!--         <small>{{ user?.firstname }} {{ user?.lastname }}</small>-->
      </h1>
      <p v-if="error">{{ error }}</p>
vue/src/router.js
@@ -8,15 +8,15 @@
import Kurse from './pages/Kurse.vue'
import KursDetail from './pages/KursDetail.vue'
const base = import.meta.env.VITE_ROUTER_BASE
const routes = [
   { path: `${base}/`, redirect: "/user" },
   { path: `${base}/ui/user`, component: Users },
   { path: `${base}/ui/user/:userId`, component: UserDetail },
   { path: `${base}/ui/kurs`, component: Kurse },
   { path: `${base}/ui/kurs/:kursId`, component: KursDetail },
   { path: `/`, redirect: "/user" },
   { path: `/ui/user`, component: Users },
   { path: `/ui/user/:userId`, component: UserDetail },
   { path: `/ui/kurs`, component: Kurse },
   { path: `/ui/kurs/:kursId`, component: KursDetail },
]
console.log(routes)
const router = createRouter({
   history: createWebHistory(),