Where are functions located?

Feels a bit silly asking this but I keep calling or visiting my function url on my deployed site (like example.com/functions/my-function), but I get a 404 response from my frontend application. What is the correct path for functions once the site has been deployed? Could anything else be happening here?
5 Replies
endymion1818
endymion18185mo ago
Locally with Wrangler it works fine on the local URL (localhost:3000/functions/my-function)
Chaika
Chaika5mo ago
it wouldn't be under /functions/ unless you had /functions/functions. Docs here: https://developers.cloudflare.com/pages/functions/routing/ I'd also make sure Pages is picking it up, the functions folder needs to be in your root folder, not build output. You can check under the Functions tab of your deployment
Routing · Cloudflare Pages docs
Functions utilize file-based routing. Your /functions directory structure determines the designated routes that your Functions will run on. You can …
endymion1818
endymion18185mo ago
Ah great thanks
Chaika
Chaika5mo ago
Your build log will say either
Note: No functions dir at /functions found. Skipping.
or
13:12:57.991 Found Functions directory at /functions. Uploading. 13:12:59.384 ✨ Compiled Worker successfully
another thing to check
endymion1818
endymion18185mo ago
Aha the problem was I had used export default which worked in Wrangler but seems to trigger the error when it's deployed.
Want results from more Discord servers?
Add your server
More Posts