Search code examples
dartdart-pub

pub serve to non-root directory


Is it possible to run pub serve during dev and have the application available on localhost:8888/application instead of localhost:8888 ?

I don't see any flags that I can specify on pub itself, so was wondering if there's some kind of transformer I can use.


Solution

  • I don't think this is possible. Maybe adding a symlink

    my_project/web/application
    

    that points to

    my_project/web
    

    allows you to do what you want.

    Another option is to use a proxy that forwards

    http://localhost:8888/application 
    

    to

    http://localhost:8080/
    

    Using a proxy is also the recommended solution when you need to use a 3rd-party server during development where requests for Dart resources are forwarded to pub serve and everything else to the 3rd-party server.