From 988b43b0ea3974c81ed713697a403ed249ee64a0 Mon Sep 17 00:00:00 2001 From: Souma <101255979+5ouma@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:41:41 +0900 Subject: [PATCH] fix(frontend): Use pre-hard-coded value for Hono RPC It's impossible to use relative URL path due to SSR. --- deno.json | 2 +- src/components/utils.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/deno.json b/deno.json index 1081f4b..8e466fa 100644 --- a/deno.json +++ b/deno.json @@ -5,7 +5,7 @@ }, "fmt": { "exclude": ["LICENSE", ".github/**/*.md"] }, "tasks": { - "run": "deno run --allow-read='./public/,./private/cocktails.jsonc' --allow-net='0.0.0.0' --unstable-kv", + "run": "deno run --allow-env='API_URL' --allow-read='./public/,./private/cocktails.jsonc' --allow-net='0.0.0.0' --unstable-kv", "start": "deno task run src/server.ts", "dev": "deno task run --watch src/server.ts", "test": "deno test --allow-read='./public/,./private/cocktails.jsonc' --allow-net='0.0.0.0' --unstable-kv --parallel --shuffle" diff --git a/src/components/utils.ts b/src/components/utils.ts index e5cc294..024a614 100644 --- a/src/components/utils.ts +++ b/src/components/utils.ts @@ -1,9 +1,10 @@ import { hc } from "@hono/hono/client"; -import { API } from "../api/mod.ts"; -import { Cocktail } from "../api/utils/types.ts"; +import type { API } from "../api/mod.ts"; +import { Cocktail, Message } from "../api/utils/types.ts"; -const client = hc("http://0.0.0.0:8000/api"); +const url: string = Deno.env.get("API_URL") || "http://0.0.0.0:8000"; +const client = hc(`${url}/api`); /** * Get cocktails from the server