Start App Router server programmatically
Answered
Trigg Hound posted this in #help-forum
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 appreciatedAnswered by joulev
in that case i think you can simply use a script to execute
next start command with a -H of your choice10 Replies
@Trigg Hound 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
have you tried simply setting the
PORT environment variable? iirc if you run the app without an explicit -H, it will use the PORT before falling back to 3000Trigg 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 locallyand setting the
-H as and env variable doesn't workas 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 choiceAnswer
Trigg HoundOP
ahhh I see
e.g. with node.js you would use
child_process to run the commandwith 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