8

I am using docsifyjs to create a documentation. But I wanted to add Authentication to access the docs.

Basically we serve the docs with following commands

Initializing docsify

docsify init ./docs

After the init is complete, you can see the file list in the ./docs subdirectory.

index.html as the entry file README.md as the home page .nojekyll prevents GitHub Pages from ignoring files that begin with an underscore

We can now serve the mark-down files as HTML with following commands.

docsify serve docs

or

cd docs && python -m SimpleHTTPServer 3000

or

npx http-server docs

Here docsify is served by giving the path of initialized directory.

But I am not able to figure out how to serve this with expressJS. So that I can add authentication. I have tried adding app.js to ./docs and added the following code but markdown files are not being rendered.

var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');

var app = express();

app.use(serveStatic('/', { 'index': ['index.html', 'index.htm'] }));
app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, 'index.html'));
})
app.listen(8000);

Please help. Thanks

4
  • Did you figure it out ?
    – Alexy
    Commented Nov 4, 2020 at 22:25
  • It is a static site generator. As fas as my research I got know we must write a proxy script for it and add authentication. But didn't find the exact solution. Commented Nov 6, 2020 at 1:33
  • This is exactly what Im trying to do but I can't figure out how. I was told there may be a way to do it with Request headers but there is limited documentation on it docsify.js.org/#/configuration?id=requestheaders Commented Feb 2, 2021 at 9:09
  • @Alexy Nope. I didnt find it yet Commented Jun 20, 2022 at 18:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.