[GH-ISSUE #498] Suggestion: Remove underscores from CSS/JS file paths for better compatibility with Cloudflare CDN #281

Closed
opened 2026-04-08 16:51:41 +03:00 by zhus · 4 comments
Owner

Originally created by @jiangtaste on GitHub (Dec 13, 2024).
Original GitHub issue: https://github.com/sigoden/dufs/issues/498

Hi there,

First of all, thank you for creating and maintaining DUFS—it’s an excellent tool!

I encountered an issue when serving DUFS through Cloudflare’s CDN. Specifically, CSS and JS file paths containing underscores (e.g., dufs_v0.43.0/index.css) are not handled correctly by Cloudflare. This leads to issues where the page cannot load styles or scripts, resulting in an improperly rendered UI.

The problem arises because underscores in URLs can cause compatibility issues in certain scenarios, as Cloudflare applies stricter rules for URL validation. This seems to be a known limitation of how some proxies or CDNs process URLs.

To address this, I would like to suggest:
1. Removing underscores (_) from the paths of CSS/JS files.
2. Replacing them with more universally compatible characters, such as dashes (-), for better compatibility with CDNs and proxies.

For example:
dufs_v0.43.0/index.css → --dufs-v0.43.0--/index.css

This change would improve the usability of DUFS in scenarios where CDNs like Cloudflare are used.

Thank you for considering this suggestion! Please let me know if further clarification is needed.

Best regards,
Paul

Originally created by @jiangtaste on GitHub (Dec 13, 2024). Original GitHub issue: https://github.com/sigoden/dufs/issues/498 Hi there, First of all, thank you for creating and maintaining DUFS—it’s an excellent tool! I encountered an issue when serving DUFS through Cloudflare’s CDN. Specifically, CSS and JS file paths containing underscores (e.g., __dufs_v0.43.0__/index.css) are not handled correctly by Cloudflare. This leads to issues where the page cannot load styles or scripts, resulting in an improperly rendered UI. The problem arises because underscores in URLs can cause compatibility issues in certain scenarios, as Cloudflare applies stricter rules for URL validation. This seems to be a known limitation of how some proxies or CDNs process URLs. To address this, I would like to suggest: 1. Removing underscores (_) from the paths of CSS/JS files. 2. Replacing them with more universally compatible characters, such as dashes (-), for better compatibility with CDNs and proxies. For example: • __dufs_v0.43.0__/index.css → --dufs-v0.43.0--/index.css This change would improve the usability of DUFS in scenarios where CDNs like Cloudflare are used. Thank you for considering this suggestion! Please let me know if further clarification is needed. Best regards, Paul
zhus closed this issue 2026-04-08 16:51:41 +03:00
Author
Owner

@sigoden commented on GitHub (Dec 13, 2024):

@jiangtaste
Is there any official documentation from Cloudflare CDN that proves underscores are discouraged or forbidden?

If there are restrictions, then why is the link below valid?
https://cdnjs.cloudflare.com/ajax/libs/material-ui/4.12.4/esm/utils/unstable_useId.min.js

<!-- gh-comment-id:2540555750 --> @sigoden commented on GitHub (Dec 13, 2024): @jiangtaste Is there any official documentation from Cloudflare CDN that proves underscores are discouraged or forbidden? If there are restrictions, then why is the link below valid? https://cdnjs.cloudflare.com/ajax/libs/material-ui/4.12.4/esm/utils/unstable_useId.min.js
Author
Owner

@jiangtaste commented on GitHub (Dec 13, 2024):

@sigoden

Thank you for your response.

I must admit that I haven’t been able to find any official documentation from Cloudflare explicitly discouraging or forbidding underscores in URLs. However, when I enabled Cloudflare’s CDN proxy for an Nginx reverse-proxied DUFS service, the page rendered blank. Interestingly, directly accessing dufs_v0.43.0/index.css worked perfectly fine, and disabling the CDN proxy resolved the issue entirely.

This behavior is puzzling, and I can only speculate that it might be related to the underscores in the URL paths. While it’s not definitive, this observation led me to suggest avoiding underscores in file paths to prevent potential compatibility issues with certain proxies or CDNs like Cloudflare.

Thank you again for looking into this!

<!-- gh-comment-id:2540616146 --> @jiangtaste commented on GitHub (Dec 13, 2024): @sigoden Thank you for your response. I must admit that I haven’t been able to find any official documentation from Cloudflare explicitly discouraging or forbidding underscores in URLs. However, when I enabled Cloudflare’s CDN proxy for an Nginx reverse-proxied DUFS service, the page rendered blank. Interestingly, directly accessing __dufs_v0.43.0__/index.css worked perfectly fine, and disabling the CDN proxy resolved the issue entirely. This behavior is puzzling, and I can only speculate that it might be related to the underscores in the URL paths. While it’s not definitive, this observation led me to suggest avoiding underscores in file paths to prevent potential compatibility issues with certain proxies or CDNs like Cloudflare. Thank you again for looking into this!
Author
Owner

@jiangtaste commented on GitHub (Dec 13, 2024):

Here is my Nginx configuration:

server {
  listen 443 ssl;
  listen [::]:443 ssl;

  ssl_certificate /etc/nginx/ssl/domain.com/cert.pem;
  ssl_certificate_key /etc/nginx/ssl/domain.com/key.pem;

  server_name dufs.domain.com;

  location / {
    proxy_pass http://127.0.0.1:5000/;

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    client_max_body_size 500m;
  }
}
<!-- gh-comment-id:2540620245 --> @jiangtaste commented on GitHub (Dec 13, 2024): Here is my Nginx configuration: ``` server { listen 443 ssl; listen [::]:443 ssl; ssl_certificate /etc/nginx/ssl/domain.com/cert.pem; ssl_certificate_key /etc/nginx/ssl/domain.com/key.pem; server_name dufs.domain.com; location / { proxy_pass http://127.0.0.1:5000/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 500m; } } ```
Author
Owner

@jiangtaste commented on GitHub (Dec 13, 2024):

Hi there,

Please disregard my previous suggestion. After further investigation, I’ve identified the issue to be caused by Cloudflare’s newly introduced Rocket Loader. Disabling Rocket Loader under Speed > Optimization > Content Optimization > Rocket Loader resolved the issue, and everything is now working as expected.

I hope this helps anyone else encountering the same problem!

<!-- gh-comment-id:2540634509 --> @jiangtaste commented on GitHub (Dec 13, 2024): Hi there, Please disregard my previous suggestion. After further investigation, I’ve identified the issue to be caused by Cloudflare’s newly introduced Rocket Loader. Disabling Rocket Loader under Speed > Optimization > Content Optimization > Rocket Loader resolved the issue, and everything is now working as expected. I hope this helps anyone else encountering the same problem!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#281