You can't access bindings during build, if that is what you mean
You can't access bindings during build, if that is what you mean
/api
npm i @cf-wasm/satori. There is 1 other project in the npm registry using @cf-wasm/satori.
npm i @cf-wasm/og. There are no other projects in the npm registry using @cf-wasm/og.
wrangler.toml and running a wrangler pages dev command results in a hanging browser. Raised it on GitHub (https://github.com/cloudflare/workers-sdk/issues/6173), then noticed the message on https://developers.cloudflare.com/pages/functions/wrangler-configuration/ that said to come here... does anyone know if this is expected behaviour or am I doing something wrong?
index.html in a directory, then run wrangler pages dev <directory>?In advanced mode, your Function will assume full control of all incoming HTTP requests to your domain. Your Function is required to make or forward requests to your project’s static assets. Failure to do so will result in broken or unwanted behavior. Your Function must be written in Module syntax.
_routes.json to exclude all paths except the ones I define explicitly (such as /api/*).Error: Failed to publish your Function. Got error: No such compatibility flag: experimental:nodejs_compat_v2dev session, then check if there are any other wrangler processes, and stop them?ps aux | grep wrangler revealed a handful of instances knocking round in the background... killed them all and problem solved! Thanks so much for your help!wrangler process(or two or three) get stuck, and don't shut down when they are supposed to, which can gum up everything elselsof -i :8787 or 8788, but these ones were on dynamic portsonRequestPost on the index.ts, no matter WTF I try, I always get a [wrangler:inf] POST /api/hotels 405 Method Not Allowed (4ms) :shrugg: it doesn't even go in (neither is my code returning this).wrangler pages dev _site while in the root folder, I'm not a directory up or down, like this guy: https://community.cloudflare.com/t/cf-pages-functions-wrangler-dev-405-method-not-allowed-locally/442767/14 besides, even if I were, my other functions would've have worked anyway.index, or with path placeholders like [id], or dedicated endpoints like /instagram. I have more than one file with 'onRequestGet' and 'onRequestPost' on them, and they work just fine./apinpm i @cf-wasm/satorinpm i @cf-wasm/ogimport { satori } from "@cf-wasm/satori"; // <- for cf workers/pages
import { satori } from "@cf-wasm/satori/next"; // <- for next js edgewrangler pages dev <directory>✘ [ERROR] Failed to register worker in local service registry TypeError: fetch failed
at fetch
(/Users/andy/=/quests/delete-me-pages/node_modules/.pnpm/wrangler@3.62.0/node_modules/wrangler/wrangler-dist/cli.js:17209:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async registerWorker
(/Users/andy/=/quests/delete-me-pages/node_modules/.pnpm/wrangler@3.62.0/node_modules/wrangler/wrangler-dist/cli.js:203827:12)
at async Object.announceAndOnReady [as onReady]
(/Users/andy/=/quests/delete-me-pages/node_modules/.pnpm/wrangler@3.62.0/node_modules/wrangler/wrangler-dist/cli.js:206237:7)
{
cause: ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout
(/Users/andy/=/quests/delete-me-pages/node_modules/.pnpm/wrangler@3.62.0/node_modules/wrangler/wrangler-dist/cli.js:6031:29)
at
/Users/andy/=/quests/delete-me-pages/node_modules/.pnpm/wrangler@3.62.0/node_modules/wrangler/wrangler-dist/cli.js:5987:51
at Immediate._onImmediate
(/Users/andy/=/quests/delete-me-pages/node_modules/.pnpm/wrangler@3.62.0/node_modules/wrangler/wrangler-dist/cli.js:6019:13)
at process.processImmediate (node:internal/timers:478:21)
at process.topLevelDomainCallback (node:domain:160:15)
at process.callbackTrampoline (node:internal/async_hooks:128:24) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
[wrangler:inf] GET / 200 OK (5989ms)_routes.json/api/*Error: Failed to publish your Function. Got error: No such compatibility flag: experimental:nodejs_compat_v2wranglerwranglerps aux | grep wranglerlsof -i :8787folderRoot/
└── functions/
└── api/
└── hotels/
└── index.tsonRequestPost[wrangler:inf] POST /api/hotels 405 Method Not Allowed (4ms)wrangler pages dev _siteindex[id]/instagramexport default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname.startsWith('/api/')) {
const apiRequest = new Request(
`https://your-worker-url.com${url.pathname}`,
request
);
return env.MY_WORKER_SERVICE.fetch(apiRequest);
}
return env.ASSETS.fetch(request);
},
};
});// functions/api/[[route]].ts
export const onRequest: PagesFunction = ({ request }) => {
const url = new URL(request.url);
url.host = "your-worker-url.com";
return fetch(url.toString(), request);
};{
"version": 1,
"include": ["/api/*"],
"exclude": ["/*"]
}