© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•3y ago•
2 replies
Oreki

ENV Variables not found

hello, i am using hono, i have two routes one is list and other is image

import { Hono } from 'hono/quick';
import { createClient } from '@supabase/supabase-js';

type Bindings = {
  SUPABASE_URL: string;
  SUPABASE_KEY: string;
  TOKEN: string;
};

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

// Routes
app.get('/image', async (context) => {
  const { env } = context

  console.log(env);
  if (!env || !env.SUPABASE_URL || !env.SUPABASE_KEY) {
    return context.json({ error: true, message: 'Environment not found' }, 500);
  }

  try {
    // ....
  } catch (error) {
    if (error instanceof Error) {
      console.log(error);
      return context.json({ error: true, message: error.message }, 500);
    }
  }
});

app.get('/list', async (context) => {
  const { env } = context;
  if (!env || !env.SUPABASE_URL || !env.SUPABASE_KEY) {
    return context.json({ error: true, message: 'Environment not found' }, 500);
  }

  const key = context.req.query('key');
  if (!key || context.env.TOKEN !== key) {
    return context.json({ error: true, message: 'Invalid token' }, 401);
  }

  try {
    // ...
  } catch (error) {
    if (error instanceof Error) {
      console.log(error);
      return context.json({ error: true, message: error.message }, 500);
    }
  }
});

export default app;
import { Hono } from 'hono/quick';
import { createClient } from '@supabase/supabase-js';

type Bindings = {
  SUPABASE_URL: string;
  SUPABASE_KEY: string;
  TOKEN: string;
};

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

// Routes
app.get('/image', async (context) => {
  const { env } = context

  console.log(env);
  if (!env || !env.SUPABASE_URL || !env.SUPABASE_KEY) {
    return context.json({ error: true, message: 'Environment not found' }, 500);
  }

  try {
    // ....
  } catch (error) {
    if (error instanceof Error) {
      console.log(error);
      return context.json({ error: true, message: error.message }, 500);
    }
  }
});

app.get('/list', async (context) => {
  const { env } = context;
  if (!env || !env.SUPABASE_URL || !env.SUPABASE_KEY) {
    return context.json({ error: true, message: 'Environment not found' }, 500);
  }

  const key = context.req.query('key');
  if (!key || context.env.TOKEN !== key) {
    return context.json({ error: true, message: 'Invalid token' }, 401);
  }

  try {
    // ...
  } catch (error) {
    if (error instanceof Error) {
      console.log(error);
      return context.json({ error: true, message: error.message }, 500);
    }
  }
});

export default app;


when i try to access to the route
/list
/list
everything works fine a supabase client is intialised and im returned number of files i have but when i go to route image i get the error that Environment not found and when i log the env it seems to be an empty object
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Not binding env variables
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Env ,Variables in Github Workflow
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Next.js requiring env variables in build variables
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
6mo ago
Help with calling/declaring env variables
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
14mo ago