Makes Node adapter respect HOST (#1365)#1366
Makes Node adapter respect HOST (#1365)#1366Rich-Harris merged 9 commits intosveltejs:masterfrom tsanth:master
Conversation
By default, the HOST variable is set to 127.0.0.1, for safety.
|
Thank you — is there a reason to default to |
|
My typical workflow is to use a local nginx instance to reverse proxy requests to Node (to simplify SSL setup, among things), so I set the default assuming that use case. Since this is for production servers, I've modifed the default to be |
|
Thank you — I took the liberty of adding a changeset and docs |
packages/adapter-node/src/index.js
Outdated
| import * as app from './app.js'; | ||
|
|
||
| const { PORT = 3000 } = process.env; // TODO configure via svelte.config.js | ||
| const { HOST = '0.0.0.0', PORT = 3000 } = process.env; // TODO configure via svelte.config.js |
There was a problem hiding this comment.
Is this TODO still a TODO? Would the env vars take precedence?
There was a problem hiding this comment.
it's still a TODO insofar as you can't specify a default port/host via the adapter config. Is that something worth having, if we have environment variables?
There was a problem hiding this comment.
Well yeah what I meant is: is this something we still want to do? I don't have especially strong opinions about that. I assume it would be additional args you pass to the adapter factory function and not somewhere else in the config.
There was a problem hiding this comment.
it would be, yeah. tbh i'm inclined to just remove the TODO comment — it's less confusing if there's only one way to set non-default values, and we need environment variables regardless so that it's configurable at runtime
By default, the HOST variable is set to 127.0.0.1, for safety.
I lack the experience to set up a test runnable via
pnpm test, but I've tested this as follows:npm run buildHOST=192.168.1.64 npm startnpm run buildHOST=192.168.1.64 npm startBefore submitting the PR, please make sure you do the following
Tests
pnpm testand lint the project withpnpm lintChangesets
pnpx changesetand following the prompts