Workers SDK Issue Reports

← Back to Dashboard

#3484 Some Function & Routing settings works in local machine, but does not work in server side

Recommendation:CLOSE
Difficulty:n/a
Reasoning:

User using regex patterns in _routes.json which only supports wildcards (*). Not a bug - expected behavior per documentation.

Suggested Action:

Close as not-a-bug. Suggest using wildcards or handling matching in function code.

Analysis Report

Issue Review: cloudflare/workers-sdk#3484

Summary

User reports _routes.json with regex patterns works locally but not in production - this is actually expected behavior as regex is not supported.

Findings

  • Created: 2023-06-17
  • Updated: 2025-10-30
  • Version: Wrangler 3.1.0 → 4.60.0
  • Component: Pages Functions (_routes.json routing)
  • Labels: bug, pages
  • Comments: 0

Key Evidence

  1. User is using unsupported syntax: The user's _routes.json uses regex patterns like /[a-z0-9]/[a-z0-9]/[a-z0-9]{32}.htm in the include array.

  2. Documentation confirms only wildcards are supported: The official documentation explicitly states:

    "Wildcards match any number of path segments (slashes). For example, /users/* will match everything after the /users/ path."

    There is no mention of regex support in _routes.json. Only * wildcards are documented.

  3. Local vs Production discrepancy: The fact that it "works locally" but not in production suggests wrangler's local development server may be more permissive in parsing route patterns than the production Pages infrastructure. This could be considered a separate bug (local dev should match production behavior).

  4. Issue recently assigned: The issue was assigned to petebacondarwin on 2025-10-21 and added to a project on 2025-12-12, suggesting active tracking.

  5. No fixing PRs found: No merged PRs reference fixing this issue, and the changelog has no mention of issue #3484.

Recommendation

Status: NEEDS MORE INFO / CLOSE AS NOT A BUG

Reasoning: This appears to be a user misunderstanding rather than a bug. The _routes.json file only supports wildcard patterns (*), not regex patterns. The user's configuration uses regex character classes ([a-z0-9]) and quantifiers ({32}) which are not part of the documented syntax. The fact that it "works locally" could indicate a separate issue where wrangler's local dev is more permissive than production, but the core request (regex support) is a feature request, not a bug.

Action: Close as "not a bug" or convert to a feature request for regex support in _routes.json. Optionally, open a separate issue to investigate why local wrangler accepts patterns that production rejects (behavior parity).

Suggested Comment

Hi @ninsiu-com, thank you for this detailed bug report!

After investigation, this appears to be a misunderstanding of the _routes.json syntax rather than a bug. The _routes.json file only supports wildcard patterns using *, not regex patterns.

Your configuration uses regex syntax:

"/[a-z0-9]/[a-z0-9]/[a-z0-9]{32}.htm"

However, the documentation states:

"Wildcards match any number of path segments (slashes). For example, /users/* will match everything after the /users/ path."

To achieve similar routing, you would need to use a broader wildcard pattern like:

"/f/*//*.htm"

Or handle the path matching logic within your [[page]].js function itself.

The fact that this worked locally but not in production does suggest a discrepancy in how wrangler's local dev server parses these patterns. If you believe regex support would be valuable, please feel free to open a feature request.

Closing this as "not a bug" since the behavior matches the documented specification. Please reopen if you have additional questions!

Notes & Feedback (1)

Add Note