Best-practices and errors for CFworkers+Hono API in monorepo

Hey guys, new to CF. I am currently building a Turborepo and have started researching cloudflare for my dedicated API. I am having some problems with doing a simple Hono app and am reaching out for help as the docs are difficult to reason with. Attached are some context images. I am getting TS errors from my TSConfig with the recent worker-configurations.d.ts typegen file. Not sure how to fix it. Outside of that issue, I am wondering, what are the best practices around CSP and CORS and environment variables? Currently using a Hono middleware with .dev.vars for environment variables, but I am not sure how to access those variables in the hono middleware for setting (for example) the allowed origin headers.
No description
No description
1 Reply
olafg
olafg2d ago
Environment variables you can define in wrangler or in the UI, keep in mind that you should use secrets for keys etc. You should be able to access them using the import {env} from "cloudflare:workers" when you import variables like this they are available globally and not just in a request context

Did you find this page helpful?