```js export default { async fetch(req, env): Promise<Response> { // https://develop
if i return "false" like this EXAMPLE, it would still count this request on my worker limits?
export default {
async fetch(req, env): Promise<Response>
{
// https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
const ipAddress = req.headers.get("cf-connecting-ip") || "";
const { success } = await env.MY_RATE_LIMITER.limit({ key: ipAddress })
if (!success)
return new Response(`429 Failure – rate limit exceeded for ${ipAddress}`, { status: 429 });npx wrangler dev --remoteblock POST requests, await fetch("https://tunnel.xxx.com/authentication", works on cloudflarenpx wrangler dev --remote on this same request i get (403) Forbidden as responsetest.com, worker worker.test.com fetching origin.test.com is a "same zone subrequest"console.log msgs from worker code somewhere on the website?

wrangler tail



blockawait fetch("https://tunnel.xxx.com/authentication",(403) Forbiddentest.comworker.test.comorigin.test.comwrangler tailimport speech from '@google-cloud/speech'
// Initialize Google Speech Client
const client = new createClient.SpeechClient({
credentials: {
client_email: env.GOOGLE_CLIENT_EMAIL,
private_key: env.GOOGLE_PRIVATE_KEY
}
});service core:user:voice-call-handler-dev: Uncaught TypeError: Cannot convert object to primitive value
at null.<anonymous> (index.js:18912:101) in isEnabled
at null.<anonymous> (index.js:18915:35) in refresh
at null.<anonymous> (index.js:18956:13) in
../node_modules/.pnpm/google-logging-utils@0.0.2/node_modules/google-logging-utils/build/src/colours.js
at null.<anonymous> (index.js:19:51) in require2
at null.<anonymous> (index.js:19013:21) in
../node_modules/.pnpm/google-logging-utils@0.0.2/node_modules/google-logging-utils/build/src/logging-utils.js
at null.<anonymous> (index.js:19:51) in require2
at null.<anonymous> (index.js:19269:18) in
../node_modules/.pnpm/google-logging-utils@0.0.2/node_modules/google-logging-utils/build/src/index.js
at null.<anonymous> (index.js:19:51) in __require2
at null.<anonymous> (index.js:19318:18) in
../node_modules/.pnpm/gcp-metadata@6.1.1/node_modules/gcp-metadata/build/src/index.jsinterface Env
{
MY_RATE_LIMITER: any;
}
export default {
async fetch(req, env): Promise<Response>
{
// https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
const ipAddress = req.headers.get("cf-connecting-ip") || "";
const { success } = await env.MY_RATE_LIMITER.limit({ key: ipAddress })
if (!success)
return new Response(`429 Failure – rate limit exceeded for ${ipAddress}`, { status: 429 });
const login = req.headers.get("x-login");
const password = req.headers.get("x-password");
if (!login || !password)
return new Response("", { status: 403 });
const isValidUser = await validateUser(login, password);
if (!isValidUser)
return new Response("", { status: 403 });
//const origin = new Request(req.url, req);
//origin.headers.delete("x-login");
//origin.headers.delete('cf-workers-preview-token');
//return fetch(origin);
return fetch(req)
},
} satisfies ExportedHandler;
async function validateUser(login: string, password: string): Promise<boolean>
{
const response = await fetch("https://tunnel.xxx.com/authentication",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ login, password })
});
// The server returns 200 for valid authentication, 403 for invalid
return response.status === 200;
}