Skip to content

Commit 46df6ce

Browse files
committed
fix: fix bug in API
1 parent 39bcfb7 commit 46df6ce

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

web2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
# React Router
66
/.react-router/
77
/build/
8+
/.vite/

web2/app/context/AccountContext.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import * as React from "react"
44
import { useNavigate } from "react-router"
55
import { type Account, getAccount, signout } from "~/backend/AccountBackend"
6-
import { initServerUrl } from "~/lib/api"
76

87
type AccountState = {
98
/** undefined = still loading; null = not signed in; Account = signed in */
@@ -19,7 +18,6 @@ export function AccountProvider({ children }: { children: React.ReactNode }) {
1918
const [account, setAccount] = React.useState<Account | null | undefined>(undefined)
2019

2120
const load = React.useCallback(() => {
22-
initServerUrl()
2321
getAccount().then((res) => {
2422
if (res.status === "ok") {
2523
setAccount(res.data ?? null)

web2/app/lib/api.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// Server URL — empty string means same-origin (production); localhost gets the backend port
2-
export let ServerUrl = ""
3-
4-
export function initServerUrl() {
5-
if (typeof window !== "undefined" && window.location.hostname === "localhost") {
6-
ServerUrl = `http://${window.location.hostname}:14000`
7-
}
8-
}
2+
export const ServerUrl =
3+
typeof window !== "undefined" && window.location.hostname === "localhost"
4+
? `http://${window.location.hostname}:14000`
5+
: ""
96

107
export function getLanguage(): string {
118
if (typeof localStorage === "undefined") return "en"

0 commit comments

Comments
 (0)