summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/env.ts1
-rw-r--r--src/index.ts8
2 files changed, 3 insertions, 6 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;