summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/env.ts1
-rw-r--r--src/index.ts8
-rw-r--r--wrangler.toml3
3 files changed, 3 insertions, 9 deletions
diff --git a/src/env.ts b/src/env.ts
index a39f506..01b9713 100644
--- a/src/env.ts
+++ b/src/env.ts
@@ -1,6 +1,5 @@
export type Bindings = {
ASSETS: Fetcher;
- URL?: string;
REDIRECT_ROOT?: string;
};
diff --git a/src/index.ts b/src/index.ts
index 397dd30..3126b15 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -26,7 +26,7 @@ app.get("/list_teawies", zValidator("query", list), async (c) => {
return c.json(
WIES.slice(0, parseInt(limit ?? "5")).map((wie) => {
return {
- url: `${c.env.URL ?? "https://api.mydadleft.me"}/${WIE_DIR}/${wie}`,
+ url: new URL(`/${WIE_DIR}/${wie}`, c.req.url).toString(),
};
}),
);
@@ -36,12 +36,10 @@ app.get("/random_teawie", (c) => {
const wie = WIES[Math.floor(Math.random() * WIES.length)];
return c.json({
- url: `${c.env.URL ?? "https://api.mydadleft.me"}/${WIE_DIR}/${wie}`,
+ url: new URL(`/${WIE_DIR}/${wie}`, c.req.url).toString(),
});
});
-app.get("/get_random_teawie", (c) => {
- return c.redirect(`${c.env.URL ?? "https://api.mydadleft.me"}/random_teawie`);
-});
+app.get("/get_random_teawie", (c) => c.redirect("/random_teawie"));
export default app;
diff --git a/wrangler.toml b/wrangler.toml
index 96060fe..21b0ea0 100644
--- a/wrangler.toml
+++ b/wrangler.toml
@@ -4,6 +4,3 @@ compatibility_date = "2023-11-11"
workers_dev = false
send_metrics = false
-
-[vars]
-URL = "https://api.mydadleft.me"