Oreki
Oreki
Explore posts from servers
CDCloudflare Developers
Created by Oreki on 9/15/2023 in #workers-help
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 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
3 replies
CDCloudflare Developers
Created by Oreki on 9/9/2023 in #pages-help
PNPM Monorepo on cloudflare pages
hello, i have a pnpm monorepo using lerna, i would like to deploy one of the apps to cloudflare pages from my monorepo heres my build configuration
Build command: pnpm install --force && cd apps/cdn && npx @cloudflare/next-on-pages@1
Build output directory: /apps/cdn/.vercel/output/static
Root directory: /
Build command: pnpm install --force && cd apps/cdn && npx @cloudflare/next-on-pages@1
Build output directory: /apps/cdn/.vercel/output/static
Root directory: /
the issue is that i cannot cd into the correct directory and its running the npx @cloudflare/next-on-pages@1 at root directory and build is failing for the same reason
6 replies