Skip to content

can't use custom hosts anymore with BuildContext.serve #4110

Closed
@brianwestphal

Description

@brianwestphal

In 0.24.2 and prior, one could use custom hosts, which was especially useful with self-signed certificates for local development.

0.25 breaks this, which is a pain. Having to run a proxy just to support https with a custom domain name seems like it wasn't the goal with the 0.25 changes.

    const serveResult = await esbuildContext.serve({
      host: process.env.HOST ?? 'localhost',
      port: Number(process.env.PORT ?? 3000),
      certfile: process.env.CERTFILE,
      keyfile: process.env.KEYFILE,
      servedir: 'build',
      fallback: 'build/index.html'
    });

If I pass a custom host name, like "www.local.myfakeserver.com" (and then, for example edit my /etc/hosts file to map www.local.myfakeserver.com to 127.0.0.1 and mark my self-signed certificates as locally trusted), I used to be able to then server to my custom domain, which was really useful.

Now it says "host not allowed".

I think hosts that are explicitly specified in the host arg for BuildContext.serve should be allowed and/or there should be another argument, like allowedHosts or something, to explicitly whitelist.

For now, I'm going back to 0.24.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions