I had an interesting issue today with Express today. I set up static files like I usually do, but intermittently I had an issue where some of the static resources (javascript files, in particular, would not load).
It turns out it was some of the other middleware slowing down the static file middleware. All I had to do was move the static file middleware higher up the stack. In fact, I added it immediately after declaring the Express application.
|
1 2 3 4 |
//Initialize the express app var app = express(); //set up the static directory app.use(express.static(path.join(__dirname, 'public'))); |
That solved the issue. Hopefully, this helps someone.



Add comment