[Bug]: Capacitor WebView treats URLs with dots as file requests, breaking SPA routing and page reload.

Aperta
#8,085 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #8135 di @iamriajul — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
android, ios, typescript
Ambito
mobile, web-dev

Direzione di ricerca

Inizia riproducendo il problema con il progetto Capacitor collegato sia su iOS che su Android, concentrandoti sulla navigazione di WebView per le route che contengono punti. Confronta queste richieste con le richieste degli asset e verifica che gli URL che non sono asset servano index.html, in modo che il routing SPA e il ricaricamento delle pagine funzionino su entrambe le piattaforme.

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

Descrizione

platform: android platform: ios type: bug
Capacitor Version

💊 Capacitor Doctor 💊

Installed Dependencies:

@capacitor/cli: 7.4.2
@capacitor/core: 7.4.2
@capacitor/android: 7.4.2
@capacitor/ios: 7.4.2

[success] iOS looking great! 👌
[success] Android looking great! 👌

Other API Details

Platforms Affected
  • iOS
  • Android
  • Web
Current Behavior

When navigating to URLs that contain dots (.) in the path, Capacitor's WebView treats them as file requests rather than SPA routes. This causes a 404 error instead of serving the index.html file for client-side routing.

For example:

  • http://localhost/@username → Works (serves index.html)
  • http://localhost/@user.name → Fails (404 - treats as file request)
  • http://localhost/page.section → Fails (404 - treats as file request)

And shows console error in Xcode:
⚡️ WebView failed provisional navigation
⚡️ Error: The file “@user.name” couldn’t be opened because there is no such file.

And in Android, An error page is shown with Page is not available.

Image
Expected Behavior

All non-asset URLs should serve index.html to allow the SPA router to handle routing, regardless of whether the URL contains dots.

Project Reproduction

https://github.com/iamriajul/capacitor-dot-in-urls-spa-navigation-issue-reproduction

Additional Information

No response

Lingua principale
TypeScript
Stelle
17.1k
Fork
1.3k
Merge medio
1g 22h
PR unite (30g)
26

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 ionic-team/capacitor

Tutte le issue di ionic-team/capacitor

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.