diff --git a/.env.development b/.env.development index 3bba0cfb..554368bd 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,5 @@ # for localhost NODE_ENV=development +VITE_APP_URL=https://app.twinte.net VITE_API_URL=https://app.twinte.net/api/v3 \ No newline at end of file diff --git a/.env.production b/.env.production index 905cc8dd..572af37e 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,7 @@ # for app.twinte.net NODE_ENV=production +VITE_APP_URL=https://app.twinte.net VITE_API_URL=https://app.twinte.net/api/v3 VITE_APP_SENTRY_URL=https://2fc5be4f95404937ada4d0127497fca4@o4504011477221376.ingest.sentry.io/4504226167324672 +VITE_APP_SENTRY_ORIGIN=app.twinte.net diff --git a/.env.staging b/.env.staging index 90344389..fc2e5979 100644 --- a/.env.staging +++ b/.env.staging @@ -1,4 +1,5 @@ # for app.dev.twinte.net NODE_ENV=development +VITE_APP_URL=https://app.dev.twinte.net VITE_API_URL=https://app.dev.twinte.net/api/v3 \ No newline at end of file diff --git a/src/ui/main.ts b/src/ui/main.ts index 19324a57..1f7fa050 100644 --- a/src/ui/main.ts +++ b/src/ui/main.ts @@ -17,7 +17,7 @@ Sentry.init({ integrations: [ new BrowserTracing({ routingInstrumentation: Sentry.vueRouterInstrumentation(router), - tracingOrigins: ["app.twinte.net"], + tracingOrigins: [import.meta.env.VITE_APP_SENTRY_ORIGIN ?? ""], }), new Sentry.Replay({ maskAllText: false, diff --git a/src/ui/templates/Layout.vue b/src/ui/templates/Layout.vue index ecee6e5e..03e459be 100644 --- a/src/ui/templates/Layout.vue +++ b/src/ui/templates/Layout.vue @@ -8,6 +8,7 @@ import { useSwitch } from "~/ui/hooks/useSwitch"; import { getAuthState, setAuthState } from "~/ui/store/auth"; import { isVisibleSidebar, closeSidebar } from "~/ui/store/sidebar"; import { deleteToast, getToasts } from "~/ui/store/toast"; +import { getAppUrl } from "~/ui/url"; import Sidebar from "./Sidebar.vue"; /** auth state */ @@ -77,7 +78,7 @@ const toasts = getToasts(); size="medium" layout="fill" color="primary" - @click="$router.push('/login?redirectUrl=https://app.twinte.net/')" + @click="$router.push(`/login?redirectUrl=${getAppUrl()}`)" > ログインする diff --git a/src/ui/url.ts b/src/ui/url.ts index 723222bc..82664781 100644 --- a/src/ui/url.ts +++ b/src/ui/url.ts @@ -13,15 +13,19 @@ export const openUrl = (url: string) => { } }; +export const getAppUrl = () => { + return import.meta.env.VITE_APP_URL ?? "https://app.twinte.net" +}; + export const getLoginUrl = ( provider: Provider, - redirectUrl = "https://app.twinte.net" + redirectUrl = getAppUrl() ) => { - return `https://app.twinte.net/auth/v3/${provider}?redirect_url=${redirectUrl}`; + return `${getAppUrl()}/auth/v3/${provider}?redirect_url=${redirectUrl}`; }; -export const getLogoutUrl = (redirectUrl = "https://app.twinte.net") => { - return `https://app.twinte.net/auth/v3/logout?redirect_url=${redirectUrl}`; +export const getLogoutUrl = (redirectUrl = getAppUrl()) => { + return `${getAppUrl()}/auth/v3/logout?redirect_url=${redirectUrl}`; }; export const getSyllabusUrl = (year: number, code: string): string => {