From bc250209d84cfaecbbcddf8b2c57a3196d79d448 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sun, 26 Jun 2022 15:24:24 +0300 Subject: [PATCH] Fix API_URL/API_DOMAIN usage in dashboard --- dashboard/src/api.ts | 2 +- dashboard/src/auth.ts | 4 ++-- dashboard/src/init-vue.ts | 2 +- dashboard/webpack.config.js | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dashboard/src/api.ts b/dashboard/src/api.ts index f6cfd5e5..6b75d1f8 100644 --- a/dashboard/src/api.ts +++ b/dashboard/src/api.ts @@ -1,5 +1,5 @@ import { RootStore } from "./store"; -const apiUrl = process.env.API_URL; +const apiUrl = `https://${process.env.API_DOMAIN}`; type QueryParamObject = { [key: string]: string | null }; diff --git a/dashboard/src/auth.ts b/dashboard/src/auth.ts index bb5c1b9e..e8c085d7 100644 --- a/dashboard/src/auth.ts +++ b/dashboard/src/auth.ts @@ -11,7 +11,7 @@ const isAuthenticated = async () => { export const authGuard: NavigationGuard = async (to, from, next) => { if (await isAuthenticated()) return next(); - window.location.href = `${process.env.API_URL}/auth/login`; + window.location.href = `https://${process.env.API_DOMAIN}/auth/login`; }; export const loginCallbackGuard: NavigationGuard = async (to, from, next) => { @@ -25,5 +25,5 @@ export const loginCallbackGuard: NavigationGuard = async (to, from, next) => { export const authRedirectGuard: NavigationGuard = async (to, form, next) => { if (await isAuthenticated()) return next("/dashboard"); - window.location.href = `${process.env.API_URL}/auth/login`; + window.location.href = `https://${process.env.API_DOMAIN}/auth/login`; }; diff --git a/dashboard/src/init-vue.ts b/dashboard/src/init-vue.ts index 614b5609..25b30969 100644 --- a/dashboard/src/init-vue.ts +++ b/dashboard/src/init-vue.ts @@ -20,7 +20,7 @@ Vue.mixin({ return { get env() { return Object.freeze({ - API_URL: process.env.API_URL, + API_URL: `https://${process.env.API_DOMAIN}`, }); }, }; diff --git a/dashboard/webpack.config.js b/dashboard/webpack.config.js index 7fb9f221..2ae878ca 100644 --- a/dashboard/webpack.config.js +++ b/dashboard/webpack.config.js @@ -1,5 +1,3 @@ -require("dotenv").config({ path: path.resolve(process.cwd(), "../.env") }); - const path = require("path"); const VueLoaderPlugin = require("vue-loader/lib/plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); @@ -154,7 +152,9 @@ let config = { js: ["./src/main.ts"], }, }), - new DotenvPlugin(), + new DotenvPlugin({ + path: path.resolve(process.cwd(), "../.env"), + }), ], resolve: { extensions: [".ts", ".tsx", ".js", ".mjs", ".vue"],