Incorrect @asset urls on dev when using bud.setpublicpath

I have this bud.config.js

     * Development URL to be used in the browser.
      port: 3000,
      host: 'localhost'
    if (app.isDevelopment) {
      app.setPublicPath(publicPath => {
        return `https://${process.env.WP_HOME}/_dev/`

and this directive in a blade template

    <img src="@asset('images/' . $logo)">

I have a frontend proxy that proxies all /_dev/ urls to the local dev server started by bud, the rest goes directly to php/wp, so navigating to https://www.example.loc/
all urls generated from css files are correct, starging with /_dev/ but the url generated from the directive is something like https://www.example.loc/app/themes/theme/public/https:/https:/www.example.loc/_dev/images/logo-light.svg

is this a configuration error?

My recommendation is to just let the bud.js proxy server handle this. For every request the proxy server:

  • checks the mimetype of the request.
  • for text/ requests it replaces the proxy origin with the dev server origin
  • all other request bodies are proxied without modification
  • cookie domain is nulled

Is there a reason this doesn’t work for you? If it’s to support SSL you can provide the key and cert as bud.serve() parameters:

  host: "example.test", // or `dev.example.test`
  port: 3000,           // with port `443` if preferred
  key: "/users/developer/certs/example.test.key",
  cert: "/users/developer/certs/example.test.crt",

Regardless, any accommodations to support your setup would need to be made in acorn, as bud doesn’t have any control over the @asset directive. I’m moving this to #acorn and updating the title accordingly.