Skip to content

feat: Serve public/index.html from root handler #1850

@craiglabenz

Description

@craiglabenz

Description

I would like to vendor a Flutter web build into Dart Frog's public directory and then serve its index.html file from Dart Frog's own root handler. I have this working in what feels like a hacky way, so I am proposing either:

  1. Documentation on a cleaner way
  2. The addition of a cleaner way, or
  3. Confirmation that this way is not actually hacky

Requirements

This is potentially a documentation request - I don't know!

Additional Context

In my root index.dart file, I have found that the following code works:

import 'package:dart_frog/dart_frog.dart';
import 'package:shelf_static/shelf_static.dart';

Future<Response> onRequest(RequestContext context) async {
  final handler = fromShelfHandler(
    createStaticHandler(
      'public',
      defaultDocument: 'index.html',
    ),
  );

  return handler(context);
}

Metadata

Metadata

Labels

featureA new feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions