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