I have a site hosted in aws with www.domain.com with 2 sub domains test.domain.com and stage.domain.com. I am using MEAN for development, now what i want is to password protected my sub domains test.domain.com and stage.domain.com but in a similar fashion as we do in php using htaccess.
Now i personally like this htaccess approach because in this approach your code for the application will be same, authentication will be added by htaccess. Any idea how to do that in nodejs without altering application code, so that i can remove that in future if i want.
P.S. : Only hints are welcomed.
.htaccess does not alter the code because it's used by the Apache webserver.
Consider that Node.js IS your webserver, so that's where the magic happens (technically, it takes less code to add basicAuth to node than to add htaccess to apache + write the .htacess file).
Something, somewhere has to know that authentication is to be done :).
Here's the link to an easy way to do that in node :
Basic HTTP authentication with Node and Express 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With