workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

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

Open R-CoderDotCom opened this issue 3 years ago • 8 comments

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

R-CoderDotCom avatar Nov 18 '22 22:11 R-CoderDotCom

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

amochkin avatar Nov 24 '22 20:11 amochkin

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

Cherry avatar Dec 08 '22 18:12 Cherry

We are fixing this problem with:

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

amochkin avatar Dec 08 '22 21:12 amochkin

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:

NullVoxPopuli avatar Dec 17 '22 21:12 NullVoxPopuli

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:

  • Be removed & replaced with a warning/error informing the user that their actual functions folder may misplaced.

  • Be user-configurable with a flag/environment variable to either remove it from the list, or suppress the above warning/error.

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

KianNH avatar Jan 05 '23 16:01 KianNH

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

targos avatar Jan 18 '23 08:01 targos

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.

Cherry avatar Aug 19 '23 15:08 Cherry

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

j0nl1 avatar Aug 17 '24 11:08 j0nl1

I believe this _routes.json file in the root directory will solve this issue, but you can't use Pages Functions at all if you do this:

{
  "version": 1,
  "include": [],
  "exclude": ["/*"]
}

Technically, you could add path patterns to include for your dynamic pages, if you have any.

Alternatively, I'm guessing this would also work:

{
  "version": 1,
  "include": ["/*"],
  "exclude": ["/functions/*"]
}

aleclarson avatar Mar 13 '25 21:03 aleclarson

@aleclarson that didn't work for me

here is what CF detects as uploaded:

Image

and here is what I have locally:

Image

tho... I do see the cloudflare/pages-action is archived now...

NullVoxPopuli avatar Mar 25 '25 21:03 NullVoxPopuli

Not sure if linked yet, but it looks like this is caused by this PR: https://github.com/cloudflare/workers-sdk/pull/2103 ?

NullVoxPopuli avatar Apr 01 '25 16:04 NullVoxPopuli