Next.js Discord

Discord Forum

Start App Router server programmatically

Answered
Trigg Hound posted this in #help-forum
Open in Discord
Trigg HoundOP
Hi all, is there a way that I can run/start the next js server programmatically, like the example with the pages router? I need to be able to configure the -H host variable for my project, but it's going to be different across the board for every production app. I saw a few examples online, but only for the pages directory. Any help is appreciated
Answered by joulev
in that case i think you can simply use a script to execute next start command with a -H of your choice
View full answer

10 Replies

Trigg HoundOP
the port doesn't really matter at this moment, I just want to be able to dynamically initialize the hostname to something like 192.168.1.2 or something like that as this app is running on multiple internal systems locally
and setting the -H as and env variable doesn't work
as far as I know those are only configurable inside the script
in that case i think you can simply use a script to execute next start command with a -H of your choice
Answer
Trigg HoundOP
ahhh I see
e.g. with node.js you would use child_process to run the command
with shell then it's a simple shell script file
Trigg HoundOP
i kinda wanted to avoid doing that, but if that's the only current solution then I suppose it will amek do
thank you @joulev