Skip to content

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

@iamriajul

Description

@iamriajul

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions