Description
I am serving a Flutter Web application using createStaticFileHandler. Navigation inside the app works correctly, but refreshing nested routes returns Route not found.
It appears that createStaticFileHandler does not fall back to index.html for nested paths (e.g. /public/register) even when defaultDocument is set.
Server configuration
final cascade = Cascade()
.add(createStaticFileHandler(
path: 'app',
defaultDocument: 'index.html',
))
.add(handler);
Folder structure
app/
public/
index.html
main.dart.js
assets/
Flutter build command
flutter build web --base-href /public/
Observed behavior
Opening /public loads the application correctly.
Navigating inside the Flutter app works.
Refreshing a nested route such as:
http://localhost:8080/public/register
returns:
Route not found
Steps To Reproduce
Create a Dart Frog server and configure static file serving:
final cascade = Cascade()
.add(createStaticFileHandler(
path: 'app',
defaultDocument: 'index.html',
))
.add(handler);
Place a Flutter Web build inside the following directory:
app/public/
index.html
main.dart.js
assets/
Build the Flutter app with:
flutter build web --base-href /public/
Start the Dart Frog server:
dart_frog dev
Open the application in the browser:
http://localhost:8080/public
Navigate to another route inside the Flutter app (for example /register).
Refresh the page.
Expected Behavior
For SPA applications (like Flutter Web), nested routes such as /public/register should fall back to:
app/public/index.html
so the client-side router can handle the route.
Additional Context
No response
Description
I am serving a Flutter Web application using createStaticFileHandler. Navigation inside the app works correctly, but refreshing nested routes returns Route not found.
It appears that createStaticFileHandler does not fall back to index.html for nested paths (e.g. /public/register) even when defaultDocument is set.
Server configuration
final cascade = Cascade()
.add(createStaticFileHandler(
path: 'app',
defaultDocument: 'index.html',
))
.add(handler);
Folder structure
app/
public/
index.html
main.dart.js
assets/
Flutter build command
flutter build web --base-href /public/
Observed behavior
Opening /public loads the application correctly.
Navigating inside the Flutter app works.
Refreshing a nested route such as:
http://localhost:8080/public/register
returns:
Route not found
Steps To Reproduce
Create a Dart Frog server and configure static file serving:
final cascade = Cascade()
.add(createStaticFileHandler(
path: 'app',
defaultDocument: 'index.html',
))
.add(handler);
Place a Flutter Web build inside the following directory:
app/public/
index.html
main.dart.js
assets/
Build the Flutter app with:
flutter build web --base-href /public/
Start the Dart Frog server:
dart_frog dev
Open the application in the browser:
http://localhost:8080/public
Navigate to another route inside the Flutter app (for example /register).
Refresh the page.
Expected Behavior
For SPA applications (like Flutter Web), nested routes such as /public/register should fall back to:
app/public/index.html
so the client-side router can handle the route.
Additional Context
No response