Skip to content
Advertisement

Tag: express

Helmet Content Security Policy Global Path not working

I am using Helmet to set up the content security policies of my web app in the backend using Express. The policies look like the following: When my app tries to access a link such as https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css. It says that it violates the styleSrc policy. But I have specified as one of the policies that https://maxcdn.bootstrapcdn.com/bootstrap is allowed, I thought

Some of the Express public files are not accessible on localhost

When I run my Node.js app on localhost, I can access for example http://localhost:3000/css/dashboard.css However, if I put a logo.png to the same directory and try http://localhost:3000/css/logo.png on my browser, I only get “Cannot GET /css/logo.png”. I tried with several browsers. In my app, the only reference to this is: expressapp.use(express.static(__dirname + ‘/public’)); The files are in a public directory

Is Express.js platform-independent?

I’m just starting out with Express.js. In the official getting started guide, they showed the following basic code: The first parameter to app.get() is a forward-slash indicating the root directory. But the slash is a backward-slash in windows systems. Does express deal with these differences automatically, or do we need to write extra code for it? When I was using

req is undefined when using req.accept inside nested function

I’ve recently come across a problem when working with the built-in req.accepts, req.acceptsLanguages, req.acceptsCharsets, and req.acceptsEncodings functions in express. I have an express middleware function like this: Which, in theory, should work. But the program keeps complaining and logs this error: The thing is, when I use req.accepts or one of those .accepts functions in the main function (acceptCheckpoint), like

Advertisement