rawwerks
rawwerks
CDCloudflare Developers
Created by rawwerks on 12/30/2023 in #pages-help
PYTHON_VERSION = null?
there is some python code in my repo, that doesn't have anything to do with the sveltekit app i'm building. installing python takes a long time and is a waste of resources - how can i override this automatically-detected dependency? can i set the version to null as an env var?
13 replies
CDCloudflare Developers
Created by rawwerks on 11/9/2023 in #workers-help
use node `stream` or workaround for sveltekit in CF?
i'm using sveltekit with CF. i'm having an issue when i import the stl npm package with import stl from 'stl';, i can run locally but it breaks on CloudFlare with this error (https://www.npmjs.com/package/stl)
[ERROR] Could not resolve "stream"
...
08:40:21.555 The package "stream" 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.
08:40:21.556
08:40:21.557 ✘ [ERROR] Could not resolve "stream"
08:40:21.557
08:40:21.557 node_modules/through/index.js:1:21:
08:40:21.557 1 │ var Stream = require('stream')
08:40:21.557 ╵
[ERROR] Could not resolve "stream"
...
08:40:21.555 The package "stream" 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.
08:40:21.556
08:40:21.557 ✘ [ERROR] Could not resolve "stream"
08:40:21.557
08:40:21.557 node_modules/through/index.js:1:21:
08:40:21.557 1 │ var Stream = require('stream')
08:40:21.557 ╵
the advice i'm getting from Cursor.sh (GPT-4) is below: The error message indicates that the package stream is not found in your project's dependencies. The stream module is a built-in Node.js module, and it seems like your project is trying to bundle it for the browser, which is causing the error. To fix this issue, you can use the resolve option in Vite's configuration to alias the stream module to a browser-compatible version. You can use the stream-browserify package for this. First, install stream-browserify:
npm install --save stream-browserify
npm install --save stream-browserify
Then, update your vite.config.js file to include the following:
import { defineConfig } from 'vite'

export default defineConfig({
// other config
resolve: {
alias: {
stream: 'stream-browserify'
}
}
})
import { defineConfig } from 'vite'

export default defineConfig({
// other config
resolve: {
alias: {
stream: 'stream-browserify'
}
}
})
This will tell Vite to use stream-browserify whenever stream is imported, which should resolve the error. --- this seems like an odd issue, maybe i just need to update node? is stream-browserify really necessary? (following these instructions still gives the same error)
17 replies
CDCloudflare Developers
Created by rawwerks on 9/22/2023 in #workers-help
worker to allow web scrape by friendly bot?
I'm using an AI app called Mendable to scrape my own website for training. CF is blocking their scraping bot when it tries to procedurally visit every page based on the sitemap. Mendable claims it would be "impossible" to know the IP range for their scraper, so I don't think I can whitelist the bot. Is there a way to write a simple worker that would allow this "friendly bot" to scrape my website?
2 replies
CDCloudflare Developers
Created by rawwerks on 9/17/2023 in #workers-help
sending HTML content to IFTTT every new post
i'm currently using CF Pages with the GitHub CI to host a Hugo website. my end goal is to be able to automatically generate social media posts for new blog posts. (using just IFTTT i can connect the RSS to LI for example, but that approach is very limited and not easy to create filters. (https://ifttt.com/applets/G7jpfrvD-rss-feed-to-linkedin)) it appears that CF tends to block the IFTTT webhook bots, so it seems like the better approach is to start from the CF Workers/Pages side (rather than using another tool to scrape my own site). as a first test, could someone advise a way that i could simply create a worker that will return the full HTML of the post/page when pinged by a webhook request? (with this set up, i could then get creative with how to format the content, filter out specific posts, etc. ) thanks!
2 replies
CDCloudflare Developers
Created by rawwerks on 8/28/2023 in #pages-help
can i schedule recurring re-deployments / re-builds?
No description
4 replies