cloudflare / cloudflare/developer-platform

Workers Routes matching does not work with orange-clouded/proxied/O2O DNS

オープン
#16 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
awaiting-response:cloudflare
主要言語
言語のデータがありません
スター
1
フォーク
0
PR マージ指標
30日以内にマージされた PR はありません

説明

### What versions & operating system are you using?

```
System:
OS: macOS 26.1
CPU: (10) arm64 Apple M1 Max
Memory: 446.03 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.17.1 - /Users/timkelty/.nvm/versions/node/v22.17.1/bin/node
npm: 10.9.2 - /Users/timkelty/.nvm/versions/node/v22.17.1/bin/npm
pnpm: 8.15.4 - /opt/homebrew/bin/pnpm
npmPackages:
@cloudflare/unenv-preset: ^2.4.1 => 2.7.9
@cloudflare/vitest-pool-workers: ^0.10.5 => 0.10.5
wrangler: ^4.26.0 => 4.46.0
```

### Please provide a link to a minimal reproduction

https://github.com/timkelty/reprocase-cloudflare-workers-routes

### Describe the Bug

When a DNS record is O2O, worker routes matching does _not_ work as expected. In this case, the _only_ pattern that seems to match is `*/*`.

## Cloudflare Account A (SaaS customer)

### DNS

```
mysite.com CNAME gateway.saasprovider.com (proxy status: proxied)
```

----------

## Cloudflare Account B (SaaS provider)

### Workers

Note: in reality, these workers routes are not set via wrangler, but I'm showing it that way to simplify. The behavior is the same.

#### `gateway_worker`

```
{
"routes": [
{
"pattern": "gateway.saasprovider.com",
"custom_domain": true
}
]
}
```

#### `gateway_worker_beta`

```
{
"routes": [
{
"pattern": "mysite.com/*",
"zone_id": ""
}
]
}
```

With this configuration, a request to `https://mysite.com/` will be incorrectly routed to the `gateway_worker`, even though the pattern matches for `gateway_worker_beta`.

The request is routed to `gateway_worker`, only because of the `custom_domain` on the worker. Without it, you'll get a Cloudflare error page.

If the record is _not-proxied_ (gray cloud), it will be routed to `gateway_worker_beta` as expected.

The only way to intercept these orange-clouded requests with a worker route is by using a `*/*` pattern, which in our case is not an option.

Relevant links:
- https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/get-started/hostname-routing/#orange-to-orange-o2o-behavior
- https://developers.cloudflare.com/workers/configuration/routing/

### Please provide any relevant error logs

_No response_

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

リンクされている最小再現から始め、ドキュメントに記載された orange-to-orange の動作と、issue に示されている Workers のルーティング設定を比較します。`mysite.com/*` と `*/*` のパターンに対する proxied リクエストと non-proxied リクエストを検証します。完了条件は、特定の worker route が proxied O2O リクエストに期待どおりマッチすることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
backend, cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。