flashblaze
flashblaze
Explore posts from servers
CDCloudflare Developers
Created by bkyerv on 4/17/2025 in #workers-help
help with astro app backend functions on cloudflare workers
4 replies
CDCloudflare Developers
Created by fisher on 4/17/2025 in #workers-help
Cloudflare Rate Limiting not being in Effect
This is my code and is working for me
cloudflareRateLimiter<Env>({
rateLimitBinding: (c) => c.env.MY_RATE_LIMITER,
keyGenerator: (c) => {
try {
const cookieData = JSON.parse(getCookie(c, getCookieName(c.env.ENVIRONMENT)) ?? '{}');
return cookieData.userId ?? c.req.header('CF-Connecting-IP') ?? '';
} catch (_err) {
deleteCookie(c, getCookieName(c.env.ENVIRONMENT), getCookieOptions(c.env.ENVIRONMENT));
return c.json({ message: 'Unauthorized' }, 401);
}
},
handler: (c) => {
deleteCookie(c, getCookieName(c.env.ENVIRONMENT), getCookieOptions(c.env.ENVIRONMENT));
return c.json(
{
message: 'Rate limit exceeded',
},
429
);
},
})
cloudflareRateLimiter<Env>({
rateLimitBinding: (c) => c.env.MY_RATE_LIMITER,
keyGenerator: (c) => {
try {
const cookieData = JSON.parse(getCookie(c, getCookieName(c.env.ENVIRONMENT)) ?? '{}');
return cookieData.userId ?? c.req.header('CF-Connecting-IP') ?? '';
} catch (_err) {
deleteCookie(c, getCookieName(c.env.ENVIRONMENT), getCookieOptions(c.env.ENVIRONMENT));
return c.json({ message: 'Unauthorized' }, 401);
}
},
handler: (c) => {
deleteCookie(c, getCookieName(c.env.ENVIRONMENT), getCookieOptions(c.env.ENVIRONMENT));
return c.json(
{
message: 'Rate limit exceeded',
},
429
);
},
})
Can you share a minimal example?
3 replies
CDCloudflare Developers
Created by bkyerv on 4/17/2025 in #workers-help
help with astro app backend functions on cloudflare workers
No description
4 replies
CDCloudflare Developers
Created by thedelanyo on 4/14/2025 in #pages-help
Deploy failed due crypto and buffer
that's weird. possible to share the code in question?
3 replies
CDCloudflare Developers
Created by Ricky U on 4/10/2025 in #general-help
Pages functions vs workers - the difference
These are some great questions! @Walshy | Workers/Pages would really love if you can get back to these whenever possible
11 replies
CDCloudflare Developers
Created by Peps on 11/14/2024 in #workers-and-pages-discussions
still weird I'm getting those high read
were you able to figure this out? i too am facing similar issues. i even set my cacheTtl to 1 day just to see whether that would help or not, but it did not
1 replies
SSolidJS
Created by flashblaze on 11/23/2024 in #support
How to use useSubmission in layout?
Damn. That did it. Thanks!
5 replies
SSolidJS
Created by flashblaze on 12/11/2022 in #support
Property 'giscus-widget' does not exist on type 'JSX.IntrinsicElements'
Will check this tonight and let you know if I find anything
15 replies
SSolidJS
Created by flashblaze on 12/11/2022 in #support
Property 'giscus-widget' does not exist on type 'JSX.IntrinsicElements'
thanks for the help!
import { createEffect, createSignal } from "solid-js";
import type { GiscusProps } from "./types";

declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
"giscus-widget": GiscusWidgetAttributes;
}
}
}

export default function Giscus({
id,
host,
repo,
repoId,
category,
categoryId,
mapping,
term,
strict,
reactionsEnabled,
emitMetadata,
inputPosition,
theme,
lang,
loading,
}: GiscusProps) {
const [mounted, setMounted] = createSignal(false);

createEffect(() => {
if (mounted()) return;
import("giscus");
setMounted(true);
});

return (
<giscus-widget
id={id}
host={host}
repo={repo}
repoid={repoId}
category={category}
categoryid={categoryId}
mapping={mapping}
term={term}
strict={strict}
reactionsenabled={reactionsEnabled}
emitmetadata={emitMetadata}
inputposition={inputPosition}
theme={theme}
lang={lang}
loading={loading}
/>
);
}
import { createEffect, createSignal } from "solid-js";
import type { GiscusProps } from "./types";

declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
"giscus-widget": GiscusWidgetAttributes;
}
}
}

export default function Giscus({
id,
host,
repo,
repoId,
category,
categoryId,
mapping,
term,
strict,
reactionsEnabled,
emitMetadata,
inputPosition,
theme,
lang,
loading,
}: GiscusProps) {
const [mounted, setMounted] = createSignal(false);

createEffect(() => {
if (mounted()) return;
import("giscus");
setMounted(true);
});

return (
<giscus-widget
id={id}
host={host}
repo={repo}
repoid={repoId}
category={category}
categoryid={categoryId}
mapping={mapping}
term={term}
strict={strict}
reactionsenabled={reactionsEnabled}
emitmetadata={emitMetadata}
inputposition={inputPosition}
theme={theme}
lang={lang}
loading={loading}
/>
);
}
this is now working w/o any errors
15 replies
SSolidJS
Created by flashblaze on 12/11/2022 in #support
Property 'giscus-widget' does not exist on type 'JSX.IntrinsicElements'
will do. i was following the pattern given in the repo but it did not work and so i tried the above code. following the repo i added the below code in vite-env.d.ts but still the same error
/// <reference types="vite/client" />

interface GiscusWidgetAttributes {
id?: string;
host?: string;
repo: `${string}/${string}`;
repoid: string;
category?: string;
categoryid?: string;
mapping: import("./lib/types").Mapping;
term?: string;
theme?: import("./lib/types").Theme;
strict?: import("./lib/types").BooleanString;
reactionsenabled?: import("./lib/types").BooleanString;
emitmetadata?: import("./lib/types").BooleanString;
inputposition?: import("./lib/types").InputPosition;
lang?: import("./lib/types").AvailableLanguage;
loading?: import("./lib/types").Loading;
}

declare namespace JSX {
interface IntrinsicElements {
"giscus-widget": GiscusWidgetAttributes;
}
}
/// <reference types="vite/client" />

interface GiscusWidgetAttributes {
id?: string;
host?: string;
repo: `${string}/${string}`;
repoid: string;
category?: string;
categoryid?: string;
mapping: import("./lib/types").Mapping;
term?: string;
theme?: import("./lib/types").Theme;
strict?: import("./lib/types").BooleanString;
reactionsenabled?: import("./lib/types").BooleanString;
emitmetadata?: import("./lib/types").BooleanString;
inputposition?: import("./lib/types").InputPosition;
lang?: import("./lib/types").AvailableLanguage;
loading?: import("./lib/types").Loading;
}

declare namespace JSX {
interface IntrinsicElements {
"giscus-widget": GiscusWidgetAttributes;
}
}
15 replies