Migmac
Migmac
CDCloudflare Developers
Created by Migmac on 4/24/2024 in #pages-help
I have different builds when building my vite-react app using cloudflare pages
I am committing the bun.lockb file to ensure the deps are the same, and locally it runs as expected, but for some reason the css file gets all weird when I run the build command through the cloudflare pages build process. exactly the same commands used, and as I mentioned the bun.lockb file is also comitted so it should be installing exactly the same. It does build, but messes somehting up in the process. Have no idea why this could be happening Any suggestions/pointers? my vite.config.ts looks like this:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import ViteYaml from '@modyfi/vite-plugin-yaml'
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [
ViteYaml(),
react(),
tsconfigPaths(),
],
base: './',
build: {
minify: true,
cssMinify: 'esbuild',
outDir: 'dist',
emptyOutDir: true,
}
})
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import ViteYaml from '@modyfi/vite-plugin-yaml'
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
plugins: [
ViteYaml(),
react(),
tsconfigPaths(),
],
base: './',
build: {
minify: true,
cssMinify: 'esbuild',
outDir: 'dist',
emptyOutDir: true,
}
})
The weird thing is the size of the css file is the same, but it is like it's broken somehow and only somethings work. 🤔
8 replies
CDCloudflare Developers
Created by Migmac on 4/14/2024 in #workers-help
Can I assign a worker binding during runtime?
Provided I have the account_id and the bucketName as well as an api key with the ability to do this, can I dynamically assign a binding to a worker on runtime?
21 replies
CDCloudflare Developers
Created by Migmac on 4/13/2024 in #workers-help
Is there any way I could setup bindings on a worker for r2_buckets from different accounts?
In my worker.toml, instead of having something like
r2_buckets = [
{ binding = "STORAGE_1", bucket_name = "storage", preview_bucket_name = "Storage (Private)" },
{ binding = "STORAGE_1_PUBLIC", bucket_name = "storage-public", preview_bucket_name = "Storage (Public)" },
]
r2_buckets = [
{ binding = "STORAGE_1", bucket_name = "storage", preview_bucket_name = "Storage (Private)" },
{ binding = "STORAGE_1_PUBLIC", bucket_name = "storage-public", preview_bucket_name = "Storage (Public)" },
]
The bucket_name is merely for the buckets in the account where this bucket will be deployed. I am wondering if there is a way to bind buckets from other accounts from within the same worker. (Without using the typical API key for every request) The goal is to be able to take advantage of the bindings usefulness isntead of having to manually craft a POST request for everything I am doing. Just wondering if there is someway to do this within wrangler.toml or if I have to end up doing something like the following:
export const buckets = [
{
account_id: '___ACCOUNT____ID___1', // for a given email 1
buckets: [
{ bucketName: 'storage', binding = "STORAGE_1" },
{ bucketName: 'storage-public', binding: 'STORAGE_1_PUBLIC' },
]
},
{
account_id: '___ACCOUNT____ID___2', // for a given email 2
buckets: [
{ bucketName: 'storage', binding = "STORAGE_2" },
{ bucketName: 'storage-public', binding: 'STORAGE_2_PUBLIC' },
]
},
export const buckets = [
{
account_id: '___ACCOUNT____ID___1', // for a given email 1
buckets: [
{ bucketName: 'storage', binding = "STORAGE_1" },
{ bucketName: 'storage-public', binding: 'STORAGE_1_PUBLIC' },
]
},
{
account_id: '___ACCOUNT____ID___2', // for a given email 2
buckets: [
{ bucketName: 'storage', binding = "STORAGE_2" },
{ bucketName: 'storage-public', binding: 'STORAGE_2_PUBLIC' },
]
},
This approach described above would manually require me to use an api key with permissions to email 1 and 2, and craft those requests by hand, as opposed to just using the bindings that "just work" Any thoughts on this would be very helpful and appreciated, thanks!
4 replies
CDCloudflare Developers
Created by Migmac on 9/18/2023 in #workers-help
crypto.randomBytes is not a function
I am trying to use the speakeasy package that depends on node:crypto By the looks of it the supported crypto version does not have crypto.randomBytes() implemented Should I implement my own or is this something that you will be supporting in the future?
3 replies
CDCloudflare Developers
Created by Migmac on 9/14/2023 in #workers-help
compatibility_flags = [ "nodejs_compat" ] not working
I get this message even after adding this flag to the wrangler.toml file
The package "http" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file to enable Node.js compatibility.
The package "http" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file to enable Node.js compatibility.
even when using different compatibility dates, currently with compatibility_date = "2023-08-15" I have also tried the legacy node_compat = true flag instead of the new compatibility_flags = [ "nodejs_compat" ] setting. Also tried running it with both and it gets mad. Also tried installing the packages manually and it keeps erroring out. Is there anything I'm doing wrong with this flag? How am I supposed to use it exactly? This is all caused by trying to include the googleapis package that has http2 (its the one thing that crashes with the legacy flag. With the new flag about 50 things show the "Add "node_compat = true" " flag
9 replies
CDCloudflare Developers
Created by Migmac on 9/14/2023 in #workers-help
How would I do require('googleapis') in a worker?
My question is pretty straightforward: How would I do
const { google } = require('googleapis')
const { google } = require('googleapis')
In a worker?
9 replies
CDCloudflare Developers
Created by Migmac on 4/25/2023 in #pages-help
MIME Type _headers help needed
I am trying to get a Unity WebGL build to deploy on pages and I can't seem to get the _headers file right I need the following files to be functional /Build/BUILD.data.gz /Build/BUILD.framework.js.gz /Build/BUILD.loader.js /Build/BUILD.wasm.gz I have tried messing around with the _headers file to no success My current _headers file looks like this:
/*.gz
Content-Encoding: gzip

/*.data.gz
Content-Type: application/octet-stream

/*.wasm.gz
Content-Type: application/wasm

/*.js
Content-Type: application/javascript

/*.js.gz
Content-Type: application/javascript
/*.gz
Content-Encoding: gzip

/*.data.gz
Content-Type: application/octet-stream

/*.wasm.gz
Content-Type: application/wasm

/*.js
Content-Type: application/javascript

/*.js.gz
Content-Type: application/javascript
I do get the following error message when trying to load the page though:
Unable to parse Build/BUILD.framework.js.gz! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: gzip" present. Check browser Console and Devtools Network tab to debug.
Unable to parse Build/BUILD.framework.js.gz! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: gzip" present. Check browser Console and Devtools Network tab to debug.
Any help would be useful. Thanks in advance
1 replies