Search code examples
node.jsauthenticationharp

How do I password protect a subdirectory of a Harp.js app


How do I password protect a subdirectory in a Harp site (running under Node)?

I want something like basic auth but for a single folder, not the whole site.


Solution

  • If you're using Harp through command line, by running harp server then you can't because then it's just a static file server and you can't do any server-side coding.

    You'll have to switch to Express (here's how to use BasicAuth with it). You can still use Harp (as a static server, like you were using it before) from within Express (as a middleware). Or you can just use Express static