Amend API URL
This commit is contained in:
@@ -1,15 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
: "${API_HOST:=http://localhost}"
|
|
||||||
: "${API_PORT:=80}"
|
|
||||||
# Create runtime config file in writable location
|
# Create runtime config file in writable location
|
||||||
cat > /runtime-config/config.js <<EOF
|
#cat > /runtime-config/config.js <<EOF
|
||||||
window.__APP_CONFIG__ = {
|
#window.__APP_CONFIG__ = {
|
||||||
API_HOST: "${API_HOST}",
|
# API_HOST: "${API_HOST}",
|
||||||
API_PORT: "${API_PORT}"
|
# API_PORT: "${API_PORT}"
|
||||||
};
|
#};
|
||||||
EOF
|
#EOF
|
||||||
|
|
||||||
# Generate nginx config from template (if using)
|
# Generate nginx config from template (if using)
|
||||||
if [ -f "/etc/nginx/templates/nginx.conf.template" ]; then
|
if [ -f "/etc/nginx/templates/nginx.conf.template" ]; then
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script src="/config.js"></script>
|
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import {useAuthStore} from "./stores/auth.ts";
|
|||||||
import SetsView from "./views/set/SetsView.vue";
|
import SetsView from "./views/set/SetsView.vue";
|
||||||
import JobsView from "./views/JobsView.vue";
|
import JobsView from "./views/JobsView.vue";
|
||||||
import {definePreset} from "@primeuix/themes";
|
import {definePreset} from "@primeuix/themes";
|
||||||
import {initConfig} from "@/util/config.ts";
|
import {getConfig, initConfig} from "@/util/config.ts";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
// Initialize configuration from window object
|
// Initialize configuration from window object
|
||||||
@@ -139,8 +139,12 @@ router.beforeEach(async (to) => {
|
|||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(ToastService)
|
app.use(ToastService)
|
||||||
|
|
||||||
|
const apiUrl = import.meta.env.PROD
|
||||||
|
? "/"
|
||||||
|
: `http://${getConfig().API_HOST}:${getConfig().API_PORT}`;
|
||||||
|
|
||||||
const axiosInstance = axios.create({
|
const axiosInstance = axios.create({
|
||||||
baseURL: '',
|
baseURL: apiUrl,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,4 @@ export function initConfig(config: Partial<AppConfig>) {
|
|||||||
|
|
||||||
export function getConfig(): AppConfig {
|
export function getConfig(): AppConfig {
|
||||||
return runtimeConfig;
|
return runtimeConfig;
|
||||||
}
|
|
||||||
|
|
||||||
export function getApiUrl() {
|
|
||||||
if (!runtimeConfig.API_HOST) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return `${runtimeConfig.API_HOST}:${runtimeConfig.API_PORT}`;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user