Tin Cap
Tin Cap
CDCloudflare Developers
Created by Tin Cap on 3/29/2024 in #pages-help
Multiple live deployments for same preview branch
I just started using Cloudflare Pages. I have a production branch and a master branch. I have the master branch setup as a deploy preview. Whenever I push to master, it creates a new deploy preview but the old one does not go away. Is there a way to change that? I now have multiple previews for the same branch.
2 replies
CDCloudflare Developers
Created by Tin Cap on 3/29/2024 in #pages-help
Can you setup multiple builds for the same branch?
I have a site that is deployed to multiple domains with different build settings. To simplify my example, say my app is something whitelabeled where I deploy the exact same app to domainA.com with something environment parameter like COMPANY=A and I deploy to domainB with something like COMPANY=B. So I need different builds for each domain. Is that possible on Pages?
1 replies
CDCloudflare Developers
Created by Tin Cap on 3/29/2024 in #pages-help
Having trouble figuring out how to setup staging environment on Pages
I'm migrating a React app from Netlify to Cloudflare pages. My production branch is production and my staging branch is master. I set up a new Cloudflare Pages project building production for my production site and master for my preview site, but the previews are prefixed with the commit SHA. I want my staging site running on a fixed subdomain like staging.mysite.com. I can't figure out how to do this.
8 replies
CDCloudflare Developers
Created by Tin Cap on 8/31/2023 in #workers-help
Possible to compute hmac-sha-256?
I'm trying to make an API request via Ably and it requires computing an hmac, specified here: https://ably.com/docs/api/token-request-spec#hmac It just says HMAC value is computed with hmac-sha-256. It doesn't look like this is supported in CF Workers? https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms Is that the case?
2 replies
CDCloudflare Developers
Created by Tin Cap on 8/31/2023 in #workers-help
Http2.Request is not a function
Is Http2 not supported in the workers runtime? I'm not familiar with http2 - this is coming from a library I'm using.
8 replies
CDCloudflare Developers
Created by Tin Cap on 8/31/2023 in #workers-help
Was service worker syntax removed from @cloudflare/workers-types?
I'm updating an old worker that I haven't updated in a few years. I was going to move it to ESM until I realized it uses a library that doesn't support ESM so I'm keeping it as a service worker. I updated @cloudflare/workers-types from 2.0.0 to the latest version and it seems the service worker format is no longer supported. The documentation still has this example:
addEventListener('fetch', event => {
event.respondWith(new Response('Hello'));
});
addEventListener('fetch', event => {
event.respondWith(new Response('Hello'));
});
https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#syntax-service-worker But the event type is no longer resolving to the Cloudflare Event type with the latest version of @cloudflare/workers-types Was support for service workers removed at some point?
1 replies
CDCloudflare Developers
Created by Tin Cap on 7/9/2023 in #workers-help
Invalid URL when initiating AssemblyScript generated WASM
I'm writing code in AssemblyScript and compiling it to WASM. AssemblyScript also generates JS bindings that work great in Node, but I'm having trouble getting them working in Cloudflare Workers. In the generated JS bindings, there is code like this this initiates the WebAssembly runtime:
export const {
memory,
your_function,
} = await (async url => instantiate(
await (async () => {
try { return await globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)); }
catch { return globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)); }
})(), {
}
))(new URL("release.wasm", import.meta.url));
export const {
memory,
your_function,
} = await (async url => instantiate(
await (async () => {
try { return await globalThis.WebAssembly.compileStreaming(globalThis.fetch(url)); }
catch { return globalThis.WebAssembly.compile(await (await import("node:fs/promises")).readFile(url)); }
})(), {
}
))(new URL("release.wasm", import.meta.url));
Inside my worker, that relative URL does not play nicely: new URL("release.wasm", import.meta.url) generates this error:
TypeError: Invalid URL
at new NodeError (node:internal/errors:399:5)
at new URL (node:internal/url:560:13)
TypeError: Invalid URL
at new NodeError (node:internal/errors:399:5)
at new URL (node:internal/url:560:13)
This works in Node in general. Is there a difference in Cloudflare that makes this not work?
5 replies
CDCloudflare Developers
Created by Tin Cap on 7/5/2023 in #workers-help
Typescript types for fetch in module syntax
I'm migrating a worker to module syntax in a typescript project. What are the types of request and context? I know env is my own interface.
export default {
fetch(request: ???, env: MyEnv, context: ???) {
return new Response('Hello');
},
};
export default {
fetch(request: ???, env: MyEnv, context: ???) {
return new Response('Hello');
},
};
`
9 replies