question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 BUG: Cloudflare pages not deploying functions

See original GitHub issue

What version of Wrangler are you using?

2

What operating system are you using?

Cloudflare Pages

Describe the Bug

Wrangler is not detecting functions routes, when deploying with Cloudflare Pgaes from github repo.

output below, when ‘/functions/api/contact.ts’ function file exists.

11:19:55.381 🚧 ‘wrangler pages <command>’ is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose
11:19:55.389
11:19:55.490 ✘ [ERROR] No routes found when building Functions directory: /opt/buildhome/repo/functions
11:19:55.491
11:19:55.491
11:19:55.491 If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose
11:19:55.502 Warning: Wrangler did not find routes when building functions. Skipping.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
chri70commented, Oct 6, 2022

Finally, Nitro seems to detect the deployment environment (see Zero-Config Providers doc), and select the right preset (in this case cloudflare_pages I presume). In the Nitro clouldflare.ts, we can see :

...
output: {
    serverDir: '{{ rootDir }}/functions'
},
...

The server directory /functions folder is emptied before each Nitro prerender. I suppose that Nuxt 3 /server folder should be used as source of functions folder but there’s some issues.

I fixed the problem by setting the environment variable NITRO_PRESET=node-server in CF settings.

1reaction
PoisnFangcommented, Nov 24, 2022

@luc122c

Also, it’s important that you run nuxt build rather than nuxt generate. When you choose the Nuxt preset, it chooses npm run generate as the default build command and /dist as the output directory.

Unfortunately that does not help those of us that that DO NOT want SSR, but still want the Cloudflare functions. With is preset you should be able to do either a SPA or SSR. nuxt build is for SSR and nuxt generate is for static/SPA. Currently it will not create the Cloudflare functions if you use nuxt generate

Read more comments on GitHub >

github_iconTop Results From Across the Web

Known issues · Cloudflare Pages docs
Here are some known bugs and issues with Cloudflare Pages: ... Functions (beta) does not currently support adding/removing polyfills, ...
Read more >
Pages deployment failed if functions are includes
I use Cloudflare pages for deploying a static nuxt 3 app and want to have one worker/functions endpoint for a contact form.
Read more >
functions dir is ignored in deploy - Cloudflare Pages
Hi there, I am deploying a simple reference website for an open source project. The reference website is automatically generated by TypeDoc ...
Read more >
Issues deploying page website - Cloudflare Community
Hey, I have an issue deploying my website on Cloudflare page. The website can be built, but it seems to have an issue...
Read more >
Debugging Pages - Cloudflare Docs
If you are not using Functions or have reviewed that your Functions configuration does not contain any errors, review the Cloudflare Status site ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found