Compare commits
9 Commits
main
...
jyte-bette
| Author | SHA1 | Date |
|---|---|---|
|
|
8013138118 | |
|
|
e20ca4654f | |
|
|
e62a0b720b | |
|
|
3d5a8bd31b | |
|
|
bdf5143165 | |
|
|
5f8f640588 | |
|
|
9be6924216 | |
|
|
21f4fb8d99 | |
|
|
8d1383cdaa |
|
|
@ -458,8 +458,6 @@ steps:
|
|||
commands:
|
||||
- cd frontend
|
||||
- cp -r dist-test dist-preview
|
||||
# Override the default api url used for preview
|
||||
- sed -i 's|http://localhost:3456|https://try.vikunja.io|g' dist-preview/index.html
|
||||
# create via:
|
||||
# `shasum -a 384 ./scripts/deploy-preview-netlify.mjs > ./scripts/deploy-preview-netlify.mjs.sha384`
|
||||
- shasum -a 384 -c ./scripts/deploy-preview-netlify.mjs.sha384
|
||||
|
|
@ -961,7 +959,6 @@ steps:
|
|||
- pnpm install --fetch-timeout 100000 --frozen-lockfile
|
||||
- pnpm run lint
|
||||
- pnpm run build
|
||||
- sed -i 's/http\:\\/\\/localhost\\:3456\\/api\\/v1/\\/api\\/v1/g' dist/index.html # Override the default api url used for developing
|
||||
|
||||
- name: static
|
||||
image: kolaente/zip
|
||||
|
|
@ -1020,7 +1017,6 @@ steps:
|
|||
- npm install -g corepack && corepack enable && pnpm config set store-dir .cache/pnpm
|
||||
- pnpm install --fetch-timeout 100000 --frozen-lockfile
|
||||
- pnpm run build
|
||||
- sed -i 's/http\:\\/\\/localhost\\:3456\\/api\\/v1/\\/api\\/v1/g' dist/index.html # Override the default api url used for developing
|
||||
|
||||
- name: static
|
||||
image: kolaente/zip
|
||||
|
|
@ -1189,6 +1185,6 @@ steps:
|
|||
|
||||
---
|
||||
kind: signature
|
||||
hmac: df9858e2b37dfddccd4892f007bbe69a61321352e94ebcf6adf82fa6560665bb
|
||||
hmac: fa5f7e841a6a53e16c02c9f1d677c9828e03c5672525221324d43c688a0a2b21
|
||||
|
||||
...
|
||||
|
|
|
|||
|
|
@ -10,3 +10,5 @@
|
|||
# SENTRY_ORG=vikunja
|
||||
# SENTRY_PROJECT=frontend-oss
|
||||
# VIKUNJA_FRONTEND_BASE=/custom-subpath
|
||||
|
||||
# DEV_PROXY=http://vikunja-backend.domain.tld
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
// This variable points the frontend to the api.
|
||||
// It has to be the full url, including the last /api/v1 part and port.
|
||||
// You can change this if your api is not reachable on the same port as the frontend.
|
||||
window.API_URL = 'http://localhost:3456/api/v1'
|
||||
window.API_URL = '/api/v1'
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@
|
|||
command = "pnpm run build"
|
||||
publish = "dist-preview"
|
||||
|
||||
[[redirects]]
|
||||
from = "/api/*"
|
||||
to = "https://try.vikunja.io/api/:splat"
|
||||
status = 200
|
||||
force = true
|
||||
|
||||
[[redirects]]
|
||||
from = "/*"
|
||||
to = "/index.html"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ export class InvalidApiUrlProvidedError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
export const checkAndSetApiUrl = (url: string | undefined | null): Promise<string> => {
|
||||
export const checkAndSetApiUrl = (pUrl: string | undefined | null): Promise<string> => {
|
||||
let url = pUrl
|
||||
if (url === '' || url === null || typeof url === 'undefined') {
|
||||
throw new NoApiUrlProvidedError()
|
||||
}
|
||||
|
|
@ -55,6 +56,7 @@ export const checkAndSetApiUrl = (url: string | undefined | null): Promise<strin
|
|||
// Check if the api is reachable at the provided url
|
||||
return configStore.update()
|
||||
.catch(e => {
|
||||
console.warn(`Could not fetch 'info' from the provided endpoint ${pUrl} on ${window.API_URL}/info. Some automatic fallback will be tried.`)
|
||||
// Check if it is reachable at /api/v1 and http
|
||||
if (
|
||||
!urlToCheck.pathname.endsWith('/api/v1') &&
|
||||
|
|
|
|||
|
|
@ -66,12 +66,24 @@ function createFontMatcher(fontNames: string[]) {
|
|||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({mode}) => {
|
||||
export default defineConfig(({command, mode}) => {
|
||||
// Load env file based on `mode` in the current working directory.
|
||||
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
|
||||
// https://vitejs.dev/config/#environment-variables
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
|
||||
switch (command) {
|
||||
case 'serve':
|
||||
// this is DEV mode
|
||||
return getServeConfig(env)
|
||||
// return getBuildConfig(env)
|
||||
case 'build':
|
||||
// build for prodution
|
||||
return getBuildConfig(env)
|
||||
}
|
||||
})
|
||||
|
||||
function getBuildConfig(env: Record<string, string>) {
|
||||
return {
|
||||
base: env.VIKUNJA_FRONTEND_BASE,
|
||||
// https://vitest.dev/config/
|
||||
|
|
@ -220,4 +232,23 @@ export default defineConfig(({mode}) => {
|
|||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getServeConfig(env: Record<string, string>) {
|
||||
// get some default settings from prod mod
|
||||
const buildConfig = getBuildConfig(env)
|
||||
// override prod settings with dev settings
|
||||
return {
|
||||
...buildConfig,
|
||||
server: {
|
||||
...buildConfig.server,
|
||||
...(env.DEV_PROXY && { proxy: {
|
||||
'/api': {
|
||||
target: env.DEV_PROXY,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
}}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue