Skip to content

Commit

Permalink
feat: add public path and base API URL to env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpestov committed Sep 24, 2024
1 parent 02627c6 commit e43dca7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_BASE_PATH=/quiver-frontend/
VITE_BASE_API_URL=https://quiver-dev.sub.uni-goettingen.de/api
4 changes: 2 additions & 2 deletions src/helpers/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { EvalDefinitions, EvaluationRun, GroundTruth, Project, Release, Workflow } from "@/types"

const baseUrlOld = 'https://raw.githubusercontent.com/OCR-D/quiver-back-end/main/data'
const baseUrl = 'https://quiver-dev.sub.uni-goettingen.de/api'
const baseUrl = import.meta.env.VITE_BASE_API_URL
async function getProjects(): Promise<Project[]> {
return await request(baseUrlOld + '/repos.json')
}
Expand Down Expand Up @@ -40,7 +40,7 @@ async function getLatestRuns(gtId?: string, workflowId?: string): Promise<Evalua
path += '/latest'
/*
TODO: Remove flattening when bug in the backend is fixed.
Bug: The data gets returned as an array of arrays that each contain a single object.
Bug: The data gets returned as an array of arrays that each contain a single object.
It should have the same structure as the data at the /runs endpoint. (array of objects)
Workaround:
Flatten the returned list to match the data structure of the /runs endpoint.
Expand Down
41 changes: 22 additions & 19 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import path from 'path'
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'

// https://vitejs.dev/config/
export default defineConfig({
base: '/quiver-frontend/',
build: {
outDir: 'dist',
},
publicDir: 'assets',
plugins: [
vue(),
VueI18nPlugin({
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
base: env.VITE_BASE_PATH,
build: {
outDir: 'dist',
},
publicDir: 'assets',
plugins: [
vue(),
VueI18nPlugin({
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,

// you need to set i18n resource including paths !
include: path.resolve(__dirname, './src/locales/**')
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
// you need to set i18n resource including paths !
include: path.resolve(__dirname, './src/locales/**')
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
}
})

0 comments on commit e43dca7

Please sign in to comment.