Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug]: [MCP/CLI] Bare loopback IP addresses (127.0.0.1:port) and hosts with ports fail to navigate due to erroneous scheme inference

Chiusa Adatta ai principianti
#43,263 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@alok-108 ci sta già lavorando.

Dal 10/10/2026.

  • #43264 di @alok-108 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
cli

Direzione di ricerca

L'inferenza dello schema si trova in checkUrlAndNavigate, in packages/playwright-core/src/tools/backend/tab.ts. Inizia leggendo questa funzione, poi verifica come il ramo catch decide tra http:// e https://, e tieni presente che new URL('example.com:8080') non genera un'eccezione. Il lavoro è completo quando 127.0.0.1:3000, 0.0.0.0:8000 e [::1]:8080 usano http:// come predefinito, example.com:8080 usa https:// come predefinito e uno schema esplicito già presente viene lasciato invariato. Cerca i test esistenti sulla navigazione tra le schede per confermare il comportamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What's going on?

In Playwright CLI and MCP server (playwright open, tab-new, browser_navigate), when opening or navigating to URLs specified without an explicit scheme:

  1. Bare loopback IP addresses fail with net::ERR_SSL_PROTOCOL_ERROR:
    When targeting local development servers on loopback IPs (e.g., 127.0.0.1:3000, 0.0.0.0:8000, [::1]:8080), navigation fails immediately:

    page.goto: net::ERR_SSL_PROTOCOL_ERROR at https://127.0.0.1:3000/
    

    This happens because checkUrlAndNavigate only checks url.startsWith('localhost') before defaulting to https://. As local development servers predominantly run on plain HTTP, forcing https:// causes SSL protocol failure.

  2. Bare hostnames with ports fail with net::ERR_ABORTED:
    When specifying a bare host with a port (e.g., example.com:8080), navigation fails:

    page.goto: net::ERR_ABORTED at example.com:8080
    

    According to the WHATWG URL standard, new URL('example.com:8080') parses successfully with protocol: "example.com:" and pathname: "8080". Because new URL(...) does not throw an error, the try / catch block in checkUrlAndNavigate is bypassed entirely, leaving the raw string without an http:// or https:// scheme.

Visual Evidence

1. Reproduction — SSL Protocol Error on Loopback IP & Aborted Custom Scheme:
MCP Bare URL Reproduction

2. Fixed Behavior — Loopback IPs and Ported Hosts Normalized Properly:
MCP Bare URL Fixed

Why does this happen?

In packages/playwright-core/src/tools/backend/tab.ts:

async checkUrlAndNavigate(url: string): Promise<string> {
  try {
    new URL(url);
  } catch (e) {
    if (url.startsWith('localhost'))
      url = 'http://' + url;
    else
      url = 'https://' + url;
  }
  this.context.checkUrlAllowed(url);
  await this.navigate(url);
  return url;
}
  • WHATWG new URL() does not throw on host:port because host: is treated as a valid scheme name if host begins with an ASCII alpha character ([a-zA-Z]).
  • Loopback IPs begin with numbers (127.0.0.1) so new URL() throws, but the catch branch only checks localhost, falling through to https:// for all IPv4/IPv6 loopback addresses.
Expected behavior
  1. URLs without an explicit scheme (^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/ or ^(about|data|blob|javascript):) should be normalized.
  2. Local loopback addresses (localhost, 127.0.0.1, 0.0.0.0, [::1]) should default to http://.
  3. Other bare hosts (e.g. example.com:8080, playwright.dev) should default to https://.
Lingua principale
TypeScript
Stelle
98k
Fork
6.6k
Merge medio
16h 1m
PR unite (30g)
309

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.