Functions prod vs dev

So i was following thie pages-functions guide: https://developers.cloudflare.com/pages/functions/get-started/ seems easy.. put in /functions folder and you good to go. so for the sake of checking its working copied the function from the guide. /functions/helloworld.js
export function onRequest(context) {
return new Response("Hello, world!")
}
export function onRequest(context) {
return new Response("Hello, world!")
}
long story short... when im deploying it localy (wrangler) it works (http://localhost:8788/helloworld). When i deploy to cloudflare it does't work, it shows the 404 page of the project. https://my-cf-domain.com/helloworld Anyone any idea why? 🙏
Cloudflare Docs
Functions - Get started · Cloudflare Pages docs
This guide will instruct you on creating and deploying a Pages Function.
9 Replies
Jürgen Leschner
@LoLesttK It took me a while to find this as well https://developers.cloudflare.com/pages/get-started/direct-upload/#functions
Drag and drop deployments made from the Cloudflare dashboard do not currently support compiling a functions folder of Pages Functions. To deploy a functions folder, you must use Wrangler. When deploying a project using Wrangler, if a functions folder exists where the command is run, that functions folder will be uploaded with the project.
Jürgen Leschner
I created this minimal repo to try it out https://github.com/jldec/pages-function
GitHub
GitHub - jldec/pages-function
Contribute to jldec/pages-function development by creating an account on GitHub.
Jürgen Leschner
Repo deployed manually using wrangler https://pages-function-7xk.pages.dev/ Same repo auto-deployed via link to GitHub https://pages-function-gh.pages.dev/
LoLesttK
LoLesttKOP3d ago
My setup is a SolidStart project.. maybe somethign with the config masses this up :\
Jürgen Leschner
if you can share the repo (or a stripped down copy which has the same problem), and details of how you deploy to Cloudflare, we could take a closer look. My understanding is that if you're using the preset: "cloudflare-pages" then solid will generate _worker.js in dist, which will override the functions directory when you deploy that. @LoLesttK It was not obvious to me from the solid docs how to force solid to generate a static-only bundle (no server, no preset). If that's what you're doing please share your app.config and clarify how you are building and deploying to pages.
LoLesttK
LoLesttKOP2d ago
yes the build generates a _worker.js file... totally my skill issue.. i was assuming i needed to configure it manually and file routing was the default. Thank you so much for help !🙏
Jürgen Leschner
aah - totally understandable - these starters are not super-clear about when they give you a static site or expect some server rendering. https://x.com/jldec/status/1875887369846755645
jldec (@jldec) on X
js frameworks would be simpler if they didn't mix client and server. 🌶️🌶️
Twitter
Jürgen Leschner
Got something working with no preset, no server - just SSG + pages functions https://github.com/jldec/create-solid-ssg/tree/main
GitHub
https://create-solid-ssg.pages.dev/. Contribute to jldec/create-solid-ssg development by creating an account on GitHub.
LoLesttK
LoLesttKOP2d ago
oh thats dope! i've tried that and it worked. Only thing is taking the Start part of the SolidStart and leaves us with Solid. which is fine because the workers just can be used as the backend. Youre a legend man! 😄

Did you find this page helpful?