Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brianwestphal opened this issue Mar 10, 2025 · 1 comment
Closed

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

brianwestphal opened this issue Mar 10, 2025 · 1 comment

Comments

@brianwestphal
Copy link

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

brianwestphal added a commit to freedom-tech-hq/main that referenced this issue Apr 6, 2025
@evanw evanw closed this as completed in a41040e Apr 23, 2025
@brianwestphal
Copy link
Author

nice! thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant