Skip to content

Commit

Permalink
fix: env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ifyour authored Apr 30, 2024
2 parents 3230161 + f82f7b9 commit bd1958a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/env.ts

This file was deleted.

8 changes: 3 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Hono } from "hono";
import { cors } from "hono/cors";

import { Home } from "./Home";
import { API_HOST } from "./env";

const app = new Hono();
const app = new Hono<{ Bindings: { API_HOST: string } }>();

app.get("/", (c) => c.html(<Home />));

Expand All @@ -13,7 +11,7 @@ app.post("/upload", cors(), async (c) => {
const file = body.file as File;
const formData = new FormData();
formData.append("file", file, file.name);
const response = await fetch(`${API_HOST}/upload`, {
const response = await fetch(`${c.env.API_HOST}/upload`, {
method: "POST",
body: formData,
});
Expand All @@ -23,7 +21,7 @@ app.post("/upload", cors(), async (c) => {
});

app.get("/file/:name", async (c) => {
const response = await fetch(`${API_HOST}/file/${c.req.param("name")}`);
const response = await fetch(`${c.env.API_HOST}/file/${c.req.param("name")}`);
return c.newResponse(response.body as ReadableStream, {
headers: response.headers,
});
Expand Down
6 changes: 6 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = "cf-image-hosting"
pages_build_output_dir = "./dist"
compatibility_date = "2024-04-30"

[env.production.vars]
API_HOST = "https://telegra.ph"

0 comments on commit bd1958a

Please sign in to comment.