Skip to content

Commit

Permalink
feat: App urlを環境変数で設定するように変更した
Browse files Browse the repository at this point in the history
  • Loading branch information
arata-nvm committed Mar 4, 2024
1 parent 80bbc76 commit 69a848c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/ui/templates/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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()}`)"
>
ログインする
</Button>
Expand Down
12 changes: 8 additions & 4 deletions src/ui/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 69a848c

Please sign in to comment.