Closed buhodev closed 8 months ago
ok got the i'll test on your deployment
Thanks. Let me know if you need anything from my end
Sure. I found the issue but i have to look what i can do. As of now it looks like #19 may be the reason. As cf has limited cpu time for every request. I have to go more deep for that.
Was this ever fixed or does sveltekit-og
still not work on Cloudflare Pages? 😟
Still trying to get it work on workers.
It's not going to work on cloudflare workers. I have tried so many times, I'm unable to make it work on edge runtime.
Thanks @theetherGit. I tried also to make it work with @resvg/resvg-js
+ satori
+ satori-html
but only at build time (not useful since it's not dynamic).
I got it working in CF Workers with just satori-html
and workers-og
.
import { Response as TResponse, Request } from "@cloudflare/workers-types";
import { ImageResponse } from "workers-og";
import { html as satoriHtml } from "satori-html";
// React stuff
import * as React from "react";
import { renderToString } from "react-dom/server";
export default {
async fetch(request: Request, env: Env): Promise<TResponse> {
// const html = I generate HTML from a React component + React.renderToString
const imageResponse = new ImageResponse(
satoriHtml(html) as React.ReactNode,
{
width: 1200,
height: 630,
fonts: [{ name: "TT Hoves Pro", data: fontData, weight: 600 }],
}
);
// Put the file in a CF bucket and respond with a URL.
},
};
You are making a direct use of workers-og
. Please try to use with sveltekit and then build it.
Between you can use @ethercorps/svelte-h2j
which can convert svelte to jsx, it can be used standalone but you will need svelte
as dependency.
Describe the bug Everything works on local but doesn't work on cloudflare pages
To Reproduce Steps to reproduce the behavior:
[my-new-project].pages.dev/en/og
To see the logs on cloudflare dashboard:
Workers & Pages
on the left sidebarView details
on the bottom right of your project cardFunctions
tab and scroll downBegin logs stream
button and wait until the Websocket connection is established.[my-new-project].pages.dev/en/og
again to trigger the function.Expected behavior The
/og
route should generate the imageScreenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.