Force my custom CSS style to the static folders and files that I'm getting from my express js server

Viewed 92

I'm serving my static Linux files and folders using Express (as a server). There's no problem with my code. Still for the sake of clarification, I'm providing the code

const express = require('express');
var serveIndex = require('serve-index');
const app = express();


var __dirname = "/media/user/"

app.use('/data', serveIndex(__dirname));
app.use ("/data", express.static(__dirname))

app.listen(3000, () => {
    console.log ("server listening at port 3000")
})

My actual problem is, I want to force my custom CSS styles (like changing font color, size of files & folders etc) to the display I'm getting upon visiting the localhost:300/data URL. This is the response I'm getting from express server

enter image description here

1 Answers

serve-index module has a way of passing path to custom stylesheet, try using stylesheet option when initializing it, like this:

app.use('/data', serveIndex(__dirname, { stylesheet: '/path/to/stylesheet/' }));
Related