Cloudflare Workers adapter for fdnext.
This package exposes the current fdnext HTTP API. For FlashMaster Classic or old FlashDetector / FDWebServer routes, deploy @itxtech/fd-server instead.
packages/cf-workers exposes the fdnext engine as a Cloudflare Worker source entry. It wraps @itxtech/fdnext-core in a standard Workers fetch() handler, providing a zero-infrastructure deployment path for the fdnext HTTP API.
The adapter is a thin bridge — all HTTP routing, response contracts, CORS, and External Link handling are delegated to the shared runtime.
The current repository deployment builds this adapter to packages/cf-workers/dist/index.js and deploys it with the Wrangler config in this package directory. The package metadata intentionally does not declare a runtime main / exports target until a publish bundle is added.
The default deployment entry is:
import worker from "./src/index";
export default worker;For custom runtime options, create a custom Worker source entry in this package and point wrangler.jsonc main at it:
import { createCfWorkersAdapter } from "./src/index";
import type { ExternalLinkProvider } from "@itxtech/fdnext-core/runtime";
const myLinks: ExternalLinkProvider = {
id: "product-page",
resolveLinks(ctx) {
if (!ctx.facts.partNumber) return [];
return [{
id: "product-page",
label: "Product page",
url: `https://example.com/parts/${encodeURIComponent(ctx.facts.partNumber)}`,
category: "datasheet",
priority: 10
}];
}
};
export default createCfWorkersAdapter({
externalLinkProviders: [myLinks]
});CORS is controlled via the FDNEXT_CORS_ORIGINS Worker environment variable:
FDNEXT_CORS_ORIGINS=*
FDNEXT_CORS_ORIGINS=https://app.example.com,https://admin.example.com
*— allow all origins- Multi-origin — comma/space separated, matched exactly against request
Origin
For Cloudflare Workers Builds, keep the allowlist in the Dashboard if it should not be committed. packages/cf-workers/wrangler.jsonc sets keep_vars: true so automatic deployments preserve existing Dashboard environment variables.
HTTP search defaults to a hard maximum of 300 results. Set FDNEXT_SEARCH_LIMIT in Worker variables to change the server-wide maximum; a request query limit can only select a smaller value.
# Local development
pnpm cf-workers:dev
# Dry-run deploy
pnpm cf-workers:deploy:dry-run
# Production deploy
pnpm cf-workers:deploySee packages/cf-workers/wrangler.jsonc for the Wrangler configuration.
| Export | Description |
|---|---|
createCfWorkersAdapter(options?) |
Create a custom Workers entrypoint with optional runtime options |
default |
Pre-configured Workers entrypoint using default settings |
- Cloudflare Workers Deployment — Full deployment guide, Wrangler config, and Workers Builds setup
- Server API — HTTP routes and response contracts
AGPL-3.0-or-later — See LICENSE for details.