It is possible to run a reverse proxy within Angel; this proxy can forward to webdev serve
, and serve content alongside your API, without needing CORS.
You just need package:angel_proxy
. The following will set up an instance of Proxy
, and forward to http://localhost:8080
:
var proxy = Proxy(http.IOClient(), Uri.parse('http://localhost:8080'),
recoverFrom404: false, recoverFromDead: false);
app.fallback(proxy.handleRequest);
app.shutdownHooks.add((_) => proxy.close());
You usually don't need to specify recoverFromDead
, so that you can serve a fallback route when the underlying server fails to respond. However, in this case, that is not desired, because we always want to see the content from build_runner
.
You can also follow this by using a VirtualDirectory
from package:angel_static
.