cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.57k stars 660 forks source link

🐛 BUG: Static page with a category named 'functions' (public/functions/index.html) gets discarded #2240

Open R-CoderDotCom opened 1 year ago

R-CoderDotCom commented 1 year ago

What version of Wrangler are you using?

0.0.0

What operating system are you using?

Windows

Describe the Bug

I have a tutorials website made with HUGO on CF Pages and the public folder of the site is hosted on GitHub. Since the general release of CF functions a couple of days ago (11/15/22) the section of my site named ‘functions’, vanished off, this is, example.com/functions/ returns a 404 despite the page exists on the repository inside the public/functions folder. It seems that CF Pages discards that section because of its name. Maybe, this behaviour could be addresed cheking if there is an index.html inside the functions folder

As I wouldn’t like to change the name of the section of my site I'm wondering if there’s any way to solve this issue that could potentially affect any page on CF Pages with a 'functions' section.

I'm writing an issue here following the advice reveived on CF community: https://community.cloudflare.com/t/cf-pages-excluding-public-functions-folder-of-a-hugo-website/436010

amochkin commented 1 year ago

Experiencing the same problem. The functions directory and its HTML contents is completely ignored.

Cherry commented 1 year ago

Another user ran into this issue today: https://canary.discord.com/channels/595317990191398933/789155108529111069/1050476515017633883

amochkin commented 1 year ago

We are fixing this problem with:

mv docs/functions docs/funcs && sed -i'.bak' 's/href=\"functions/href=\"funcs/g' docs/*.html
NullVoxPopuli commented 1 year ago

I had to do this:

mv dist/functions dist/funcs  
find ./dist -type f -name '*.html' \
  | xargs sed -i.bak --regexp-extended 's:(href="[^"]+)functions/:\1funcs/:g' 

to account for deeply nested html files, and functions appearing anywhere in the href due to relative pathing.

Cloudflare, this took too long for me to figure out (I'm not a sed expert), and I shouldn't have to do this anyway. Not happy. :cry:

KianNH commented 1 year ago

This is a relatively old issue now that's impacted numerous users - with the symptoms made worse that there is no output to indicate that the functions folder is being ignored.

https://github.com/cloudflare/wrangler2/blob/32686e42b055c786f9821bbd66dd33960ab8f4d1/packages/wrangler/src/pages/upload.tsx#L111-L120

Can't this either:

At the very least, users should be made aware that folders are being ignored.

targos commented 1 year ago

Hello, we just stumbled upon this issue while deploying a Storybook v7 build. In our case, part of the build files are in a node_modules directory. For example: /sb-addons/node_modules/%40storybook/addon-essentials/dist/controls/manager-bundle.mjs

Cherry commented 1 year ago

People are still hitting this bug: https://discord.com/channels/595317990191398933/1142480994734178346/1142480994734178346

It used to work quite some time ago, but https://github.com/cloudflare/workers-sdk/pull/2103 introduced this as a breaking change. That PR fixed other things, but this functionality was never revisited as a regression.

j0nl1 commented 3 weeks ago

I just created a script that solve this issue. It could be include in your pipeline using the next code:

      - name: Build Doc
        run: |
          # Replace with your doc command
          pnpm doc
          curl -O https://gist.githubusercontent.com/j0nl1/7f9b5210c9e6ecbabe322baa16dcb5db/raw/760de77327bf83671cfb6bd4e64181299ba26113/typedoc-fix-cf.mjs
          # Replace docs for your folder path it uses the folder where was downloaded like root path (its a mandatory provide a path)
          node typedoc-fix-cf.mjs docs