Wrangler login is not working

Not redirected after authorization with wrangler login.

I checked from Ports in VS Code and when I run wrangler login, the port localhost:8976 is activated.

However, the OAuth redirect does not terminate successfully and times out.

error logs


--- 2024-05-15T23:00:49.609Z debug
🪵  Writing logs to "/home/vscode/.config/.wrangler/logs/wrangler-2024-05-15_23-00-49_540.log"
---

--- 2024-05-15T23:00:49.609Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open '.env'
    at Object.openSync (node:fs:573:18)
    at Object.readFileSync (node:fs:452:35)
    at tryLoadDotEnv (/usr/local/share/nvm/versions/node/v20.13.1/lib/node_modules/wrangler/wrangler-dist/cli.js:158864:72)
    at loadDotEnv (/usr/local/share/nvm/versions/node/v20.13.1/lib/node_modules/wrangler/wrangler-dist/cli.js:158873:12)
    at /usr/local/share/nvm/versions/node/v20.13.1/lib/node_modules/wrangler/wrangler-dist/cli.js:200232:20
    at /usr/local/share/nvm/versions/node/v20.13.1/lib/node_modules/wrangler/wrangler-dist/cli.js:165275:16
    at maybeAsyncResult (/usr/local/share/nvm/versions/node/v20.13.1/lib/node_modules/wrangler/wrangler-dist/cli.js:163496:44)
    at /usr/local/share/nvm/versions/node/v20.13.1/lib/node_modules/wrangler/wrangler-dist/cli.js:165274:14
    at /usr/local/share/nvm/versions/node/v20.13.1/lib/node_modules/wrangler/wrangler-dist/cli.js:163483:22
    at Array.reduce (<anonymous>) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.env'
}
---

--- 2024-05-15T23:00:49.613Z log
 ⛅️ wrangler 3.56.0
e[38;2;255;136;0m-------------------e[39m
---

--- 2024-05-15T23:00:49.613Z log
Attempting to login via OAuth...
---

--- 2024-05-15T23:00:49.617Z log
Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20ssl_certs%3Awrite%20constellation%3Awrite%20ai%3Awrite%20queues%3Awrite%20offline_access&state=1-~lgclUchC9coOWuZ4daFdEN0BzM0Yq&code_challenge=rE_yArSNq_zdjgpKioKCTYpWXUeXwprm--o0Pl3D8gc&code_challenge_method=S256
---

--- 2024-05-15T23:00:49.637Z warn
e[33m▲ e[43;33m[e[43;30mWARNINGe[43;33m]e[0m e[1mFailed to opene[0m


---

--- 2024-05-15T23:02:49.651Z error
e[31m✘ e[41;31m[e[41;97mERRORe[41;31m]e[0m e[1mTimed out waiting for authorization code, please try again.e[0m


---

--- 2024-05-15T23:02:49.664Z debug
No folder available to cache configuration
---

--- 2024-05-15T23:02:53.417Z log
Your choice has been saved in the following file: ../../home/vscode/.config/.wrangler/metrics.json.

  You can override the user level setting for a project in `wrangler.toml`:

   - to disable sending metrics for a project: `send_metrics = false`
   - to enable sending metrics for a project: `send_metrics = true`
---

--- 2024-05-15T23:02:53.419Z debug
Metrics dispatcher: Posting data {"type":"event","name":"login user","properties":{}}
---

I have confirmed that it works on WSL (Ubuntu).
However, wrangler login does not seem to work properly on Mac DevContainer.