James
James
Explore posts from servers
CDCloudflare Developers
Created by James on 10/2/2024 in #workers-help
What is the pricing for cloudflare workers rate limiting API
4 replies
CDCloudflare Developers
Created by James on 7/30/2024 in #general-help
R2 render the html page and trigger xss
I run a service where users can upload any files and share them with others. Recently, I noticed that when users upload an HTML file containing a script tag, it triggers an XSS (Cross-Site Scripting) vulnerability when others visit that location. What measures can I take to prevent XSS attacks in this scenario?
3 replies
CDCloudflare Developers
Created by James on 7/18/2024 in #pages-help
Astro Cloudflare Pages SyntaxError: Unexpected token 'with'
No description
19 replies
CDCloudflare Developers
Created by James on 6/17/2024 in #workers-help
Slow uploads of files from the client browser to the R2 bucket using a presigned URL.
Hey guys, I notice slow uploads of files from the client browser to the R2 bucket using a presigned URL. Sometimes, the file upload also fails. The R2 bucket doesn't have public access and doesn't have a custom domain. Is this causing the issue? Are they rate limiting the upload requests? Do I need to assign a custom domain? Sometimes, when I send the PUT request to the presigned URL, it hangs and doesn't respond for 2-3 minutes. I tried to test with a 15MB file, but the issue remains the same.
2 replies
KKinde
Created by James on 5/7/2024 in #💻┃support
Is there any Honoj SDK you provide, as it is for my separate backend?
I use your TypeScript SDK with hono js but it not provide csrf protection
8 replies
KKinde
Created by James on 5/7/2024 in #💻┃support
Can we use our own mail server to send mail like aws ses?
.
2 replies
CDCloudflare Developers
Created by James on 4/8/2024 in #workers-help
Does enabling `nodejs_compat` in Cloudflare Workers slow down the worker's performance?
Is there any performance impact?
7 replies
CDCloudflare Developers
Created by James on 2/1/2024 in #workers-help
❌ [ERROR] Error in ProxyController: Error inside ProxyWorker
✘ [ERROR] Error in ProxyController: Error inside ProxyWorker

{
name: 'Error',
message: 'Network connection lost.',
stack: 'Error: Network connection lost.'
}
✘ [ERROR] Error in ProxyController: Error inside ProxyWorker

{
name: 'Error',
message: 'Network connection lost.',
stack: 'Error: Network connection lost.'
}
I am using Hono.js. I encounter an error when repeatedly sending requests, around 10 requests per second, through a middleware. In this middleware, I check if the user's IP is exceed limit in KV and then pass them through the route. The error arises during this process. Middleware
export const CheckLimitExceed = async (c: RequestT, next: Next) => {
try {
const { KV, ENVIRONMENT } = env<ENV>(c, 'workerd');

const ip =
ENVIRONMENT === 'development'
? '127.0.0.1'
: c.req.header('x-real-ip') || c.req.header('cf-connecting-ip');
const key = generateKvKey(ip);
if (!key) {
return c.json(
{
success: false,
err: true,
message: 'Bad Request',
},
400
);
}

const value = await KV.get(key);

if (!value) {
await KV.put(key, '1', { expirationTtl: expire_time });
await next();
return;
}

if (Number(value) >= PER_DAY_SHARING_LIMIT) {
return c.json(
{
success: false,
err: true,
message: `Limit exceeded for today. Please try again later.`,
},
403
);
}

await next();
} catch (err) {
return c.json(
{
success: false,
err: true,
message: 'Internal Server Error',
},
500
);
}
};
export const CheckLimitExceed = async (c: RequestT, next: Next) => {
try {
const { KV, ENVIRONMENT } = env<ENV>(c, 'workerd');

const ip =
ENVIRONMENT === 'development'
? '127.0.0.1'
: c.req.header('x-real-ip') || c.req.header('cf-connecting-ip');
const key = generateKvKey(ip);
if (!key) {
return c.json(
{
success: false,
err: true,
message: 'Bad Request',
},
400
);
}

const value = await KV.get(key);

if (!value) {
await KV.put(key, '1', { expirationTtl: expire_time });
await next();
return;
}

if (Number(value) >= PER_DAY_SHARING_LIMIT) {
return c.json(
{
success: false,
err: true,
message: `Limit exceeded for today. Please try again later.`,
},
403
);
}

await next();
} catch (err) {
return c.json(
{
success: false,
err: true,
message: 'Internal Server Error',
},
500
);
}
};
And pass that middleware like this: Route
router.get('/example/:id', CheckLimitExceed, getData);
router.get('/example/:id', CheckLimitExceed, getData);
2 replies
KKinde
Created by James on 12/29/2023 in #💻┃support
How to allow specific emails to login with auth0?
I want to only allow specific user to login with google login how to do that in kinde?
3 replies
CDCloudflare Developers
Created by James on 10/19/2023 in #workers-help
BullMQ not working with cloudflare Workers!
const connection = new IORedis(c.env.REDIS_URL);
const sendEmailQ = new Queue('sendEmailQ', { connection });
const connection = new IORedis(c.env.REDIS_URL);
const sendEmailQ = new Queue('sendEmailQ', { connection });
Error
node_modules/bullmq/dist/esm/classes/child.js:2:23:
2import { Worker } from 'worker_threads';
~~~~~~~~~~~~~~~~

The package "worker_threads" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error
node_modules/bullmq/dist/esm/classes/child.js:2:23:
2import { Worker } from 'worker_threads';
~~~~~~~~~~~~~~~~

The package "worker_threads" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error
is there any way or alternative package which i use with cloudflare workers.
2 replies