Closed vickytnz closed 1 month ago
@vickytnz @paulrobertlloyd I’m not even sure if updating the Procfile
from web: npm run serve
to web: http-server ./_site --username $USERNAME --password $PASSWORD -p $PORT
would work on Heroku – wouldn’t that then skip the npm run build
step which is run before npm run serve
using preserve
?
I wonder if a simpler approach would be to change the guidance to remove any reference to editing the Procfile
, leaving that as web: npm run serve
, and then instead suggest that if you want a password, setting NODE_HTTP_SERVER_USERNAME
and NODE_HTTP_SERVER_PASSWORD
, which http-server
will then apply by default?
Downside is that they are longer environment variable names...
I did get the above working on heroku (after 4 hours of messing around 🥴 ) - before that it either built or had a password, not both. I do agree that from my reading it started to feel like it was doing things to Procfile that should not be done to procfile, however,this is beyond my expertise, as I've already done a lot of stackoverflow just to get this to work!
4 hours! oh no. Hopefully we can improve that for others...
Was the only change you made the one above to the Procfile in the end? I'm still not quite sure how that would run the build step...
Tried out Frankie's note and it worked:
web: npm run serve
as per the original (i.e this doesn't need to change)NODE_HTTP_SERVER_USERNAME
and NODE_HTTP_SERVER_PASSWORD
(not the standard USERNAME and PASSWORD)Frankie’s updated guidance has now been merged. Sorry about this; easy to change something 18 months after originally building something, without realising all the different side-effects of doing so. Hopefully now this template repo npw works automatically with GitHub pages, and with Heroku, and the guidance for adding a password is more straight forward.
Thanks @frankieroberto 👍
The current guidance says to change the procfile (which could actually say delete and replace) with
web: http-server --username $USERNAME --password $PASSWORD -p $PORT
However everything has been changed to _site so this needs to be
web: http-server ./_site --username $USERNAME --password $PASSWORD -p $PORT
As in the package file