Open Tienisto opened 1 year ago
Second this. Just found out this package and willing to try it out. Surprised that this isn't a thing. Is there currently any workaround? Worse case is to serve static files separately behind a reverse proxy I guess.
There is a workaround without a proxy:
https://github.com/VeryGoodOpenSource/dart_frog/issues/90#issuecomment-1244807334
routes/
- index.dart
import 'dart:io';
import 'package:dart_frog/dart_frog.dart';
import 'package:path/path.dart' as path;
Response onRequest(RequestContext context) {
final file = File(path.join(Directory.current.path, 'public', 'index.html'));
if (!file.existsSync()) {
return Response(body: 'Index Not found');
}
final indexHtml = file.readAsStringSync();
return Response(body: indexHtml, headers: {'Content-Type': 'text/html'});
}
Thanks for the heads-up!
Description
I have a single page application written in Vue which gets compiled into public/
I think it is pragmatic to serve
index.html
in public by default for/
if there is no/
controller in dart code