diff --git a/src/api/client.ts b/src/api/client.ts index d1c186a..d0369cd 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -1,6 +1,5 @@ import { initAuth } from '../stores/auth.ts' - -const BASE_URL = 'http://localhost:8080' +import { API } from '../main.ts' export async function apiFetch( path: string, @@ -8,7 +7,7 @@ export async function apiFetch( ): Promise { const auth = await initAuth() - const res = await fetch(`${BASE_URL}${path}`, { + const res = await fetch(`${API}${path}`, { ...options, headers: { 'Content-Type': 'application/json', diff --git a/src/api/messages.ts b/src/api/messages.ts index 2d9e116..9abb18a 100644 --- a/src/api/messages.ts +++ b/src/api/messages.ts @@ -15,3 +15,7 @@ export function sendMessage(roomUuid: string, content: string) { }) } +export async function getWsToken(roomUuid: string): Promise { + const data = await apiFetch<{ token: string }>(`/ws/issue-token/rooms/${roomUuid}`); + return data.token; +} diff --git a/src/main.ts b/src/main.ts index 5ddd84a..1b900d3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,3 +7,6 @@ import './base.css' createApp(App) .use(router) .mount('#app') + +export const API = 'http://127.0.0.1:8080' +export const API_WS = 'ws://127.0.0.1:8080/ws' diff --git a/src/pages/ChatPage.vue b/src/pages/ChatPage.vue index 067a0c8..fbb5372 100644 --- a/src/pages/ChatPage.vue +++ b/src/pages/ChatPage.vue @@ -11,39 +11,72 @@ + + +