Yes, it is possible to prevent Nodejs express session from loading session for static content by using a middleware to check the request path and skipping the session middleware if the request is for static content. For example:
app.use((req, res, next) => {
if (req.path.startsWith('/static')) {
return next();
}
return sessionMiddleware(req, res, next);
});
In this example, the middleware checks if the request path starts with '/static'. If it does, it skips the session middleware and passes the request to the next middleware. If not, it calls the session middleware as usual.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-05-01 11:00:00 +0000
Seen: 11 times
Last updated: Apr 06 '23
How can additional centered content be added to Bootstrap 5 images?
How can an object be transferred from an injected page script to a content script?
How can a FlatList with multiple rows be made horizontal using React Native?
Is it true that the presence of "&" in a website's URL is overlooked while scraping its content?
What is the usage or application of innerHTML when using xPath?
What measures can be taken to avoid obtaining character(0) while using rvest for web scraping?
How can I substitute the content in the textInput field?
What does the error message "Invalid character in header content ['Host']" mean in Postman?