0

I have a Sveltekit app which must register itself through our backend by sending a request containing it's name and the port of the webserver. I'm trying to move this logic away from build-time file copying into hooks.server.ts, but am having trouble figuring out how to obtain the dynamically bound port. Is there a way to get it?

kalkronline
  • 459
  • 2
  • 12

1 Answers1

0

See Environment Variables or PORT, Host, and Socket Path section in the SvelteKit docs. From those docs:

In production, .env files are not automatically loaded. To do so, install dotenv in your project...

npm install dotenv ...and invoke it before running the built app:

node -r dotenv/config build

Or you can configure it manually with

HOST=127.0.0.1 PORT=4000 node build

Jason Holtzen
  • 183
  • 2
  • 10